Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring in #1

Closed
wants to merge 280 commits into from
Closed
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
280 commits
Select commit Hold shift + click to select a range
bd4d9c0
Added documentation for WhatsSendHandler.cs
Photonios Jan 31, 2013
562a311
Added documentation for WhatsNetwork.cs
Photonios Jan 31, 2013
7d523d8
Added documentation to WhatsApp.cs
Photonios Jan 31, 2013
1588016
Added documentation to WhatsConstants.cs
Photonios Jan 31, 2013
d39b2c4
Added documentation to WhatsParser.cs
Photonios Jan 31, 2013
152b766
Added documentation to WhatsEventHandler.cs
Photonios Jan 31, 2013
6efcdd2
Added documentation for MessageRecvResponse.cs
Photonios Jan 31, 2013
c82900f
Merge pull request #27 from TheKirk/master
perezdidac Jan 31, 2013
2162871
Added gitignore
shirioko Jun 6, 2013
004fbe0
Adde MediaUploader placeholder (TODO)
shirioko Jun 6, 2013
4033fbb
Added ContactSync
shirioko Jun 6, 2013
6730dcf
Updated Program.cs
shirioko Jun 6, 2013
d66cc66
Changed accessors for MissVenom
shirioko Jun 6, 2013
e05e197
The "other" changes...?
shirioko Jun 6, 2013
33ce658
Argh!
shirioko Jun 6, 2013
857d420
Added media upload request
shirioko Jun 7, 2013
f7cc05d
Fixed continuous receipt replay
shirioko Jun 7, 2013
416bcd0
Updated useragent and token
shirioko Jun 7, 2013
6d566ad
LINE BREAKS WAT R U DOIN? STAHP!
shirioko Jun 7, 2013
0de42b3
Updated chat host
shirioko Jun 10, 2013
a4436ed
Updated media sending
shirioko Jun 10, 2013
e3abe97
Partially fixed media upload
shirioko Jun 10, 2013
f17e0a7
Deleted output
shirioko Jun 10, 2013
7c9b134
Added image thumbnails
shirioko Jun 10, 2013
42081b7
Cleanup
shirioko Jun 11, 2013
a0d2651
Removed node data from debug output
shirioko Jun 13, 2013
4609922
Added debug check
shirioko Jun 13, 2013
e6a4f01
Fixes
shirioko Jun 13, 2013
1ca9a21
Methods to request and register a code for WhatsApp users.
mainlyer Jun 14, 2013
6ed39e1
Rename WhatsRegisterV2 to WhatsRegisterV2.cs
mainlyer Jun 14, 2013
48f95b3
Merge pull request #1 from mainlyer/6ed39e14a97f592bc5c192203b0dd6318…
shirioko Jun 14, 2013
fb5ca51
Added exception handling for contact sync
shirioko Jul 12, 2013
e0058e1
Merge branch 'master' of https://github.com/shirioko/WhatsAPINet
shirioko Jul 12, 2013
650d6e8
Updated client details to WP7
shirioko Jul 12, 2013
0f97481
Included WhatsRegisterV2.cs in project
shirioko Jul 12, 2013
3a998f5
Fixed WhatsRegisterV2 errors
shirioko Jul 12, 2013
c6af3f0
Updated code request URL
shirioko Jul 12, 2013
11269c3
Changed identity from MD5 to SHA
shirioko Jul 12, 2013
2c0dabe
Returned ToMD5String method for token generation
shirioko Jul 12, 2013
73a8196
Removed V1 registration
shirioko Jul 12, 2013
e9393ab
Added automatically sending nickname on login
shirioko Jul 12, 2013
af1569d
Updated example project
shirioko Jul 12, 2013
7094b66
Added RequestExist to WhatsRegisterV2.cs
shirioko Jul 12, 2013
3355171
Fixed SHA string encoding
shirioko Jul 15, 2013
fad27d1
Updated user agent to latest version
shirioko Jul 26, 2013
a91c400
Added WhatsConstant user agent to contact sync
shirioko Jul 26, 2013
ddfa4d1
Fixed encoding for all platforms
shirioko Jul 26, 2013
c9f6247
Updated to Android client details
shirioko Jul 29, 2013
f3766a8
removing whitespaces
fraga Aug 17, 2013
acceb92
Revert "Removed V1 registration"
fraga Aug 17, 2013
7f1b270
Merge pull request #2 from fraga/smallRefactor
shirioko Aug 19, 2013
b5728a0
Translation
shirioko Aug 19, 2013
0e8549b
Added WhatSocket class
shirioko Aug 19, 2013
41ea3bb
Implemented WhatSocket class for Login screen
shirioko Aug 19, 2013
9232e07
Added WhatSocket.Instance to WhatsAppPort
shirioko Aug 19, 2013
4066be0
Updated to latest working registration info
shirioko Aug 20, 2013
ca91624
Added registration form placeholder
shirioko Aug 20, 2013
f3bea4e
Fixed group panels and more
shirioko Aug 20, 2013
7fc9c4d
Renamed code input textbox
shirioko Aug 20, 2013
9ca9887
Added code request functionality
shirioko Aug 20, 2013
97a04a3
Added code register functionality
shirioko Aug 20, 2013
8ad4461
Latest changes
shirioko Aug 20, 2013
d43f065
Added cc and phone splitting in codeRequest
shirioko Aug 21, 2013
304d1d1
Added WhatsAppReg project
shirioko Aug 21, 2013
163f547
Added precompiled exe of WhatsAppReg
shirioko Aug 21, 2013
ac4adb8
Added handling of password response on codeRequest
shirioko Aug 21, 2013
7eb1c46
Updated WhatsAppReg to work with updated code
shirioko Aug 21, 2013
5367c7f
Step3 to new method to prevent duplicate code
shirioko Aug 21, 2013
fc7f5f6
Updated code to build with new V2 Reg code
shirioko Aug 21, 2013
c29a5aa
Added changes from WhatsAppReg to WhatsAppPort
shirioko Aug 21, 2013
743463f
Updated WhatsApiReg with latest WhatsAppApi.dll
shirioko Aug 21, 2013
b2ee388
Updated precompiled exe
shirioko Aug 21, 2013
4a59a72
Added optional identity parameter to V2 reg
shirioko Aug 21, 2013
1f6d644
Fixed making multiple requests
shirioko Aug 21, 2013
a990787
Added phone number parser
shirioko Aug 22, 2013
e9c3c7c
Added optional params language, locale and mcc
shirioko Aug 22, 2013
6811584
Updated WhatsAppReg to use phone number parser
shirioko Aug 22, 2013
b2de65f
Fixed warnings
shirioko Aug 22, 2013
9457288
Updated precompiled build to latest version
shirioko Aug 22, 2013
88b9174
Added optional salt for autogenerated hash
shirioko Aug 23, 2013
19cfc02
Added method to remove duplicate code
shirioko Aug 23, 2013
d737f0f
Removed WhatsAppReg (moved to WART repo)
shirioko Aug 23, 2013
ba798b4
Added receipt ack
shirioko Aug 24, 2013
2d87112
Added response output to code request
shirioko Aug 27, 2013
52e3b99
Fixed detected CC for North America
shirioko Aug 27, 2013
9c8d264
Merge pull request #47 from shirioko/master
perezdidac Aug 28, 2013
a47b4ff
Removed old unused class
shirioko Aug 30, 2013
26c7e34
Removed registration token and build hash
shirioko Aug 30, 2013
588385d
Added getToken method
shirioko Aug 30, 2013
9ef0c12
Fixed MCC splitting
shirioko Sep 6, 2013
7dfc919
Added iplimit detection and urlencode method
shirioko Sep 6, 2013
7eaff89
Updated README.md
shirioko Sep 6, 2013
abb4d67
Added offline token generator
shirioko Sep 25, 2013
fd882db
Updated to latest version details
shirioko Sep 25, 2013
324a165
Implemented offline token generator
shirioko Sep 25, 2013
51b5f32
Removed old code
shirioko Sep 29, 2013
8295cc2
Changed FunXMPP to port 443 (proxy safe)
shirioko Sep 29, 2013
5a3619c
Merge branch 'master' of https://github.com/perezdidac/WhatsAPINet
shirioko Oct 9, 2013
fcfd953
Update README.md
shirioko Oct 9, 2013
8f5cc37
Renamed class and property
shirioko Oct 17, 2013
e69d368
Updated client details to 2.11.102
shirioko Oct 18, 2013
6eb0637
Updated client details to 2.11.113
shirioko Nov 1, 2013
f8bbed8
Updated to version 2.11.125
shirioko Nov 11, 2013
444c0a4
Added SetPhoto method wrapper
shirioko Nov 15, 2013
8238909
Updated client details to 2.11.134
shirioko Nov 20, 2013
5886c85
Added response output to exist request
shirioko Nov 21, 2013
2e5e6c5
Update ProtocolTreeNode.cs
shirioko Nov 26, 2013
f5a9221
Added MessageVideo
shirioko Nov 26, 2013
7b4d33c
Added MessageAudio
shirioko Nov 26, 2013
928f6ef
Merge branch 'master' of https://github.com/perezdidac/WhatsAPINet
shirioko Nov 26, 2013
0446b41
Changed GetJID to static method
shirioko Dec 2, 2013
8d1e177
Added message broadcasting
shirioko Dec 2, 2013
28ab585
Updated client details to 2.11.139
shirioko Dec 5, 2013
4bda5aa
Added SendUnavailable and fixed messages
shirioko Dec 5, 2013
b4cbc78
Added hiding online status
shirioko Dec 5, 2013
f5dca73
Added JID conversion to SendGetPhoto
shirioko Dec 6, 2013
675b5d1
Updated to 2.11.144
shirioko Dec 13, 2013
45ba8ab
Rewritten hidden mode handling
shirioko Dec 13, 2013
4ac575a
Added overloaded codeRequest method
shirioko Dec 13, 2013
61c840e
Added GetJID to group methods
shirioko Dec 17, 2013
501154d
Added group query response handling
shirioko Dec 17, 2013
2db4a95
Removed secondary ID generation
shirioko Dec 17, 2013
6e5b436
Updated FMessage identifier
shirioko Dec 17, 2013
e06e3f3
Cleaned up all secondary id generation
shirioko Dec 17, 2013
c160a1f
First draft of new event system
shirioko Dec 17, 2013
9a02622
More events
shirioko Dec 17, 2013
bda85b4
Changed WhatsUser method to use generic GetJID
shirioko Dec 23, 2013
bff3b0d
Finished up events in WhatsApp.cs
shirioko Dec 23, 2013
c900ba4
Updated example project to use events
shirioko Dec 23, 2013
50df336
Updated client details to Android 2.11.151
shirioko Dec 24, 2013
2f99fd5
Fixed array out of bounds exception
shirioko Dec 24, 2013
c6e2229
Updated events (again)
shirioko Dec 24, 2013
f31da05
Fixed parsing location to double
shirioko Dec 27, 2013
d5b1c27
Merge branch 'master' of https://github.com/shirioko/WhatsAPINet
shirioko Dec 27, 2013
7177cd6
Fixed nullPointerException in media upload
shirioko Jan 2, 2014
65335e4
Merge branch 'master' of https://github.com/shirioko/WhatsAPINet
shirioko Jan 2, 2014
42c0698
Fixed onGetMessageDelegate
shirioko Jan 4, 2014
145a40a
Added SendSync
shirioko Jan 23, 2014
5e4dd16
Got WAUTH2 to finally work
shirioko Jan 28, 2014
bdd9b9b
Removed deprecated files
shirioko Jan 28, 2014
33623b2
Fixed text message handler
shirioko Jan 28, 2014
179746c
Implementing new WAUTH2 FunXMPP
shirioko Jan 28, 2014
b736b96
Bedtime checkin
shirioko Jan 28, 2014
3606cf6
Fixed sending text messages
shirioko Jan 29, 2014
031cbbd
Working sync and event handler
shirioko Feb 13, 2014
bf099c8
Fixed message receipts
shirioko Mar 6, 2014
a6f9928
Fixed chat states (typing/paused)
shirioko Mar 6, 2014
6770523
FUCK YOU GIT!
shirioko Mar 15, 2014
2798aa6
Added option to not auto receipt messages
shirioko Mar 16, 2014
a6092d6
Changed default auto receipt to true
shirioko Mar 16, 2014
29f5297
Changed sendMessageReceived to public
shirioko Mar 16, 2014
201c6c4
Fixed media upload & sending
shirioko Mar 16, 2014
5320da2
Res bump to 2.11.200
shirioko Mar 22, 2014
50ca409
Fixed group functions
shirioko Mar 23, 2014
c2ba637
Fixed setting profile picture
shirioko Mar 23, 2014
24ab926
fixed setting profile picture
shirioko Mar 25, 2014
0620c24
Updated registration constants to 2.11.209
shirioko Apr 8, 2014
710f25a
Updated version details to 2.11.224
shirioko Apr 19, 2014
9cded2b
Added buffered reading of socket
shirioko Apr 24, 2014
359c796
Removed while loop in Socket_read
shirioko Apr 24, 2014
29a74c7
Cleaned up login and inbound data processing
shirioko Apr 24, 2014
f83442d
Don't throw exception on receiving 0 bytes
shirioko Apr 24, 2014
4b3b7e9
Revert "Removed while loop in Socket_read"
shirioko Apr 24, 2014
a1952b6
Added sleep when waiting for incoming data
shirioko Apr 24, 2014
43d80b9
Cleaned up auth header
shirioko Apr 24, 2014
368bfdf
Fixed server and client receipt events
shirioko Apr 24, 2014
2b8e5f7
Fixed media upload
shirioko Apr 24, 2014
94d3689
Fixed nullPointerException on empty response
shirioko Apr 25, 2014
3f256a4
Improved exception handling on socket disconnect
shirioko Apr 25, 2014
ff9d196
Added oneshot login using nextChallenge data
shirioko Apr 25, 2014
1e3b274
Added oneshot login to WhatsTest project
shirioko Apr 25, 2014
f6833a9
Added exception handling on sending data
shirioko Apr 25, 2014
2c8b56b
Moved WhatsSendHandler code to WhatsApp
shirioko Apr 25, 2014
835b9e6
Removed unused property in FMessage
shirioko Apr 25, 2014
2a5892e
Removed unused classes
shirioko Apr 25, 2014
f183e16
Added MNC to countries.csv
shirioko Apr 25, 2014
b53b357
Modified PhoneNumber to use new MNC data
shirioko Apr 25, 2014
3f98cde
Fixed WhatsAppPort build errors
shirioko Apr 25, 2014
bde2fb6
Added exception handler for Socket_send
shirioko Apr 25, 2014
35b53b1
HurrDurr
shirioko Apr 25, 2014
490a128
Added sendGetStatuses()
shirioko Apr 25, 2014
bacb51a
Moved node handlers into separate methods
shirioko Apr 25, 2014
7724c0f
Abstracted out WA stuff into separate classes
shirioko Apr 25, 2014
f7831d4
Added result handler for sendGetStatuses()
shirioko Apr 25, 2014
93434e3
More abstraction
shirioko Apr 25, 2014
7acf6d1
Moved base classes to Base subdir
shirioko Apr 25, 2014
fe1690b
Moar abstraction!!!1!
shirioko Apr 25, 2014
98cc7c5
Added subject notification placeholder
shirioko Apr 26, 2014
fa90ca4
Added placeholder for contact notification
shirioko Apr 28, 2014
704f22d
Fixed SendGetServerProperties
shirioko Apr 28, 2014
9c76572
Simplified calls to registration functionality
shirioko Apr 28, 2014
5384f87
Fixed registration call in WhatsAppPort
shirioko Apr 28, 2014
0b7bcd1
Fixed WhatsTest build errors
shirioko Apr 29, 2014
ee2f4bb
support for Windows and Unix line breaks in csv
shirioko Apr 29, 2014
a8c61c0
Delete old condition to capture lastseen
w33ds92 Apr 30, 2014
47d5f82
Merge pull request #126 from w33ds92/patch-1
shirioko Apr 30, 2014
2775c78
Fixed format string
shirioko Apr 30, 2014
0d084d5
Use absolute path for nexchallenge.dat
shirioko May 1, 2014
7467228
Added placeholder for participant notification
shirioko May 31, 2014
173ff1a
Updated reg details to 2.11.254
shirioko May 31, 2014
80e9549
Added privacy settings
shirioko May 31, 2014
fbbc335
Added requesting privacy settings from server
shirioko May 31, 2014
b3a4b88
Cleaned up and added handler for privacy settings
shirioko May 31, 2014
2237c54
Cleaned up unnecessary code
shirioko May 31, 2014
7d2dc75
Moved some code to new ApiBase superclass
shirioko May 31, 2014
c9940f1
Fixed privacy category names
shirioko May 31, 2014
38301de
Added event for getting privacy settings
shirioko May 31, 2014
ada9bcd
Added DebugAdapter helper class
shirioko May 31, 2014
be91109
Removed all calls to console object from API
shirioko May 31, 2014
57d2c69
Fixed 501 error when not providing full JID
shirioko May 31, 2014
d780ccd
Added MessageVcard
shirioko May 31, 2014
dba7967
Automatic GJID conversion in SendAddParticipants
shirioko May 31, 2014
60c8980
Fixed broadcast
shirioko Jun 1, 2014
59ef433
Merge branch 'master' of https://github.com/perezdidac/WhatsAPINet
shirioko Jun 1, 2014
beb6748
Removed all System.IO.File calls from WhatsAppApi
shirioko Jun 1, 2014
f71472b
Normalized method names
shirioko Jun 1, 2014
599ee6b
Abstracted out FMessage generation for media
shirioko Jun 1, 2014
a069046
Fixed stupid typos
shirioko Jun 1, 2014
47aaa17
Added image, audio & video broadcast support
shirioko Jun 1, 2014
9271270
Fixed build errors in WhatsAppPort
shirioko Jun 1, 2014
6cb543c
Fixed errors and added more handlers in WhatsTest
shirioko Jun 1, 2014
95c3851
Added trimming of 0 and + in GetJID
shirioko Jun 1, 2014
de6b9b9
Added message id return to SendMessage
shirioko Jun 13, 2014
1167c95
Fixed null pointer when parsing sync result
shirioko Jun 13, 2014
381983d
Automatically add '+' sign to numbers before sync
shirioko Jun 13, 2014
97b2a78
Updated client details to 2.11.264
shirioko Jul 1, 2014
3742b66
Meh
shirioko Jul 1, 2014
11cac90
Updated client details to 2.11.272
shirioko Jul 1, 2014
e3a5ea6
Fixed SendDeleteAccount
shirioko Jul 29, 2014
d392ee9
Auto convert to JID in participant manipulation
shirioko Jul 31, 2014
9812206
Merge branch 'master' of https://github.com/perezdidac/WhatsAPINet
shirioko Jul 31, 2014
c93689b
Fixed some nullPointer exceptions
shirioko Aug 1, 2014
8b51679
Fixed SendStatusUpdate
shirioko Aug 1, 2014
43d60cd
Added raw data length output to NodeString
shirioko Aug 1, 2014
ab8b2b9
Added image processor helper methods
shirioko Aug 1, 2014
f699cbf
Removed modification of buffer sizes
shirioko Aug 1, 2014
17305cd
Automatically pre-process profile picture & thumb
shirioko Aug 1, 2014
563ad43
Made thumbnailBytes in SendSetPhoto optional
shirioko Aug 1, 2014
de342b2
Changed ClearDirty to protected
shirioko Aug 1, 2014
b1d6570
Added support for group creation callback
shirioko Aug 1, 2014
cf76f26
Added node to all message delegates
shirioko Aug 1, 2014
5db70c9
Added participant notification events
shirioko Aug 1, 2014
c7ee4bd
Added timestamp to DateTime conversion methods
shirioko Aug 1, 2014
1553189
Added participant notification handler
shirioko Aug 1, 2014
67b9fee
Added subject notification handler
shirioko Aug 1, 2014
8f40ea1
Configure SyncMode and Synccontext as enum
shirioko Aug 1, 2014
1b8e5cc
Changed accessors
shirioko Aug 1, 2014
00d32f1
Name in SendAvailableForChat is optional
shirioko Aug 1, 2014
edaab46
Update frmRegister.cs
bpanigrahi Aug 6, 2014
0d02bf5
Merge pull request #187 from bpanigrahi/patch-1
shirioko Aug 6, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions WhatsAppApi/Helper/ContactSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected string _getPostfields(string[] contacts)
foreach (string contact in contacts)
{
string con = contact;
if(!con.Contains('+'))
if (!con.Contains('+'))
{
con = "%2B" + con;
}
Expand All @@ -59,9 +59,16 @@ protected string _executeSync(string cnonce, string[] contacts)
{
writer.Write(postfields);
}
HttpWebResponse response = this.request.GetResponse() as HttpWebResponse;
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();
try
{
HttpWebResponse response = this.request.GetResponse() as HttpWebResponse;
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();
}
catch (Exception)
{
return null;
}
}

protected string _getSyncNonce()
Expand Down Expand Up @@ -93,7 +100,7 @@ protected static string _hash(string data)

protected static string _hash(string data, bool raw)
{
byte[] bytes = System.Text.Encoding.Default.GetBytes(data);
byte[] bytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(data);
MD5 md5 = MD5.Create();
md5.ComputeHash(bytes);
if (!raw)
Expand All @@ -102,7 +109,7 @@ protected static string _hash(string data, bool raw)
}
else
{
return System.Text.Encoding.Default.GetString(md5.Hash);
return Encoding.GetEncoding("ISO-8859-1").GetString(md5.Hash);
}
}

Expand All @@ -119,7 +126,7 @@ protected static string _hexEncode(byte[] data)
protected void _setHeaders(string nonce, long contentlength)
{
this.request.Headers.Clear();
this.request.UserAgent = "WhatsApp/2.4.7 S40Version/14.26 Device/Nokia302";
this.request.UserAgent = WhatsAppApi.Settings.WhatsConstants.UserAgent;
this.request.Accept = "text/json";
this.request.ContentType = "application/x-www-form-urlencoded";
string foo = this._generateAuth(nonce);
Expand All @@ -134,7 +141,7 @@ protected string _generateAuth(string nonce)
string nc = "00000001";
string digestUri = "WAWA/s.whatsapp.net";
string credentials = this.username + ":s.whatsapp.net:";
credentials += System.Text.Encoding.Default.GetString(Convert.FromBase64String(this.password));
credentials += Encoding.GetEncoding("ISO-8859-1").GetString(Convert.FromBase64String(this.password));
string response = _hash(_hash(_hash(credentials, true) + ":" + nonce + ":" + cnonce) + ":" + nonce + ":" + nc + ":" + cnonce + ":auth:" + _hash("AUTHENTICATE:" + digestUri));
return "X-WAWA:username=\"" + this.username + "\",realm=\"s.whatsapp.net\",nonce=\"" + nonce + "\",cnonce=\"" + cnonce + "\",nc=\"" + nc + "\",qop=\"auth\",digest-uri=\"" + digestUri + "\",response=\"" + response + "\",charset=\"utf-8\"";
}
Expand All @@ -153,4 +160,4 @@ public class ContactSyncResultContainer
{
public ContactSyncResult[] c { get; set; }
}
}
}
61 changes: 61 additions & 0 deletions WhatsAppApi/Parser/PhoneNumber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace WhatsAppApi.Parser
{
public class PhoneNumber
{
public string Country;
public string CC;
public string Number;
public string FullNumber
{
get
{
return this.CC + this.Number;
}
}
public string ISO3166;
public string ISO639;
public string MCC;

public PhoneNumber(string number)
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WhatsAppApi.Parser.countries.csv"))
{
using (var reader = new StreamReader(stream))
{
string csv = reader.ReadToEnd();
string[] lines = csv.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines)
{
string[] values = line.Split(new char[] { ',' });
//try to match
if (number.StartsWith(values[1]))
{
//matched
this.Country = values[0].Trim(new char[] { '"' });
//hook: Fix CC for North America
if (values[1].StartsWith("1"))
{
values[1] = "1";
}
this.CC = values[1];
this.Number = number.Substring(this.CC.Length);
this.ISO3166 = values[3].Trim(new char[] { '"' });
this.ISO639 = values[4].Trim(new char[] { '"' });
this.MCC = values[2];
return;
}
}
//could not match!
throw new Exception(String.Format("Could not dissect phone number {0}", number));
}
}
}
}
}
254 changes: 254 additions & 0 deletions WhatsAppApi/Parser/countries.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
"Afghanistan",93,412,"AF","ps"
"Albania",355,276,"AL","sq"
"Alberta",1403,302,"CA","en"
"Alberta",1780,302,"CA","en"
"Algeria",213,603,"DZ","ar"
"Andorra",376,213,"AD","ca"
"Angola",244,631,"AO","pt"
"Anguilla",1264,"365","AI","en"
"Antarctica (Australian bases)",6721,232,"AQ","en"
"Antigua and Barbuda",1268,"344","AG","en"
"Argentina",54,722,"AR","es"
"Armenia",374,283,"AM","hy"
"Aruba",297,363,"AW","nl"
"Ascension",247,658,"AC","en"
"Australia",61,505,"AU","en"
"Austria",43,232,"AT","de"
"Azerbaijan",994,400,"AZ","az"
"Bahamas",1242,"364","BS","en"
"Bahrain",973,426,"BH","ar"
"Bangladesh",880,470,"BD","bn"
"Barbados",1246,"342","BB","en"
"Belarus",375,257,"BY","be"
"Belgium",32,206,"BE","nl"
"Belize",501,702,"BZ","es"
"Benin",229,616,"BJ","fr"
"Bermuda",1441,"350","BM","en"
"Bhutan",975,402,"BT","dz"
"Bolivia",591,736,"BO","es"
"Bosnia and Herzegovina",387,218,"BA","bs"
"Botswana",267,652,"BW","en"
"Brazil",55,724,"BR","pt"
"British Columbia", 1250,302,"CA","en"
"British Columbia", 1604,302,"CA","en"
"British Columbia", 1778,302,"CA","en"
"British Indian Ocean Territory",246,348,"IO","en"
"British Virgin Islands",1284,"348","GB","en"
"Brunei",673,528,"BN","ms"
"Bulgaria",359,284,"BG","bg"
"Burkina Faso",226,613,"BF","fr"
"Burundi",257,642,"BI","rn"
"Cambodia",855,456,"KH","km"
"Cameroon",237,624,"CM","fr"
"Cape Verde",238,625,"CV","pt"
"Cayman Islands",1345,"346","GB","en"
"Central African Republic",236,623,"CF","sg"
"Chad",235,622,"TD","fr"
"Chile",56,730,"CL","es"
"China",86,"460|461","CN","en"
"Colombia",57,732,"CO","es"
"Comoros",269,654,"KM","fr"
"Democratic Republic of the Congo",243,630,"CD","fr"
"Republic of the Congo",242,629,"CG","fr"
"Cook Islands",682,548,"CK","en"
"Costa Rica",506,658,"CR","es"
"Cote d'Ivoire",712,"612","CI","fr"
"Croatia",385,219,"HR","hr"
"Cuba",53,368,"CU","es"
"Cyprus",357,280,"CY","el"
"Czech Republic",420,230,"CZ","cs"
"Denmark",45,238,"DK","da"
"Djibouti",253,638,"DJ","fr"
"Dominica",1767,"366","DM","en"
"Dominican Republic",1809,"370","DO","es"
"Dominican Republic",1829,"370","DO","en"
"East Timor",670,514,"TL","pt"
"Ecuador",593,740,"EC","es"
"Egypt",20,602,"EG","ar"
"El Salvador",503,706,"SV","es"
"Equatorial Guinea",240,627,"GQ","es"
"Eritrea",291,657,"ER","ti"
"Estonia",372,248,"EE","et"
"Ethiopia",251,636,"ET","am"
"Falkland Islands",500,750,"FK","en"
"Faroe Islands",298,288,"FO","fo"
"Fiji",679,542,"FJ","en"
"Finland",358,244,"FI","fi"
"France",33,208,"FR","fr"
"French Guiana",594,742,"GF","fr"
"French Polynesia",689,547,"PF","fr"
"Gabon",241,628,"GA","fr"
"Gambia",220,607,"GM","en"
"Gaza Strip",970,0,"PS","ar"
"Georgia",995,282,"GE","ka"
"Germany",49,262,"DE","de"
"Ghana",233,620,"GH","ak"
"Gibraltar",350,266,"GI","en"
"Greece",30,202,"GR","el"
"Greenland",299,290,"GL","kl"
"Grenada",1473,"352","GD","en"
"Guadeloupe",590,340,"GP","fr"
"Guam",1671,"535","GU","en"
"Guatemala",502,704,"GT","es"
"Guinea",224,611,"GN","fr"
"Guinea-Bissau",245,632,"GW","pt"
"Guyana",592,738,"GY","pt"
"Haiti",509,372,"HT","fr"
"Honduras",504,708,"HN","es"
"Hong Kong",852,454,"HK","zh"
"Hungary",36,216,"HU","hu"
"Iceland",354,274,"IS","is"
"India",91,"404|405|406","IN","hi"
"Indonesia",62,510,"ID","id"
"Iraq",964,418,"IQ","ar"
"Iran",98,432,"IR","fa"
"Ireland (Eire)",353,272,"IE","en"
"Israel",972,425,"IL","he"
"Italy",39,222,"IT","it"
"Jamaica",1876,"338","JM","en"
"Japan",81,"440|441","JP","ja"
"Jordan",962,416,"JO","ar"
"Kazakhstan",7,401,"KZ","kk"
"Kenya",254,639,"KE","sw"
"Kiribati",686,545,"KI","en"
"Kuwait",965,419,"KW","ar"
"Kyrgyzstan",996,437,"KG","ky"
"Laos",856,457,"LA","lo"
"Latvia",371,247,"LV","lv"
"Lebanon",961,415,"LB","ar"
"Lesotho",266,651,"LS","st"
"Liberia",231,618,"LR","en"
"Libya",218,606,"LY","ar"
"Liechtenstein",423,295,"LI","de"
"Lithuania",370,246,"LT","lt"
"Luxembourg",352,270,"LU","fr"
"Macau",853,455,"MO","pt"
"Republic of Macedonia",389,294,"MK","mk"
"Madagascar",261,646,"MG","mg"
"Malawi",265,650,"MW","ny"
"Malaysia",60,502,"MY","en"
"Maldives",960,472,"MV","dv"
"Mali",223,610,"ML","fr"
"Malta",356,278,"MT","mt"
"Manitoba",1204,302,"CA","en"
"Marshall Islands",692,551,"MH","mh"
"Martinique",596,340,"MQ","fr"
"Mauritania",222,609,"MR","ar"
"Mauritius",230,617,"MU","en"
"Mayotte",262,654,"YT","fr"
"Mexico",52,334,"MX","es"
"Federated States of Micronesia",691,550,"FM","en"
"Moldova",373,259,"MD","ru"
"Monaco",377,212,"MC","fr"
"Mongolia",976,428,"MN","mn"
"Montenegro",382,297,"ME","sr"
"Montserrat",1664,"354",MS,"en"
"Morocco",212,"604","MA","ar"
"Mozambique",258,643,"MZ","pt"
"Myanmar",95,414,"MM","my"
"Namibia",264,649,"NA","en"
"Nauru",674,536,"NR","na"
"Netherlands",31,204,"NL","nl"
"Netherlands Antilles",599,362,"AN","nl"
"Nepal",977,429,"NP","ne"
"New Brunswick",1506,302,"CA","en"
"New Caledonia",687,546,"NC","fr"
"New Zealand",64,530,"NZ","en"
"Newfoundland",1709,302,"CA","en"
"Nicaragua",505,710,"NI","es"
"Niger",227,614,"NE","fr"
"Nigeria",234,621,"NG","ha"
"Niue",683,555,"NU","en"
"Norfolk Island",6723,505,"NF","en"
"North Korea",850,467,"KP","ko"
"Northern Mariana Islands",1670,"534","MP","en"
"Northwest Territories",1867,302,"CA","en"
"Norway",47,242,"NO","nb"
"Nova Scotia",1902,302,"CA","en"
"Oman",968,422,"OM","ar"
"Ontario",1416,302,"CA","en"
"Ontario",1519,302,"CA","en"
"Ontario",1613,302,"CA","en"
"Ontario",1647,302,"CA","en"
"Ontario",1705,302,"CA","en"
"Ontario",1807,302,"CA","en"
"Ontario",1905,302,"CA","en"
"Pakistan",92,410,"PK","en"
"Palau",680,552,"PW","en"
"Palestine",970,425,"PS","ar"
"Panama",507,714,"PA","es"
"Papua New Guinea",675,537,"PG","ho"
"Paraguay",595,744,"PY","es"
"Peru",51,716,"PE","es"
"Philippines",63,515,"PH","fil"
"Poland",48,260,"PL","pl"
"Portugal",351,268,"PT","pt"
"Qatar",974,427,"QA","ar"
"Quebec",1418,302,"CA","en"
"Quebec",1450,302,"CA","en"
"Quebec",1514,302,"CA","en"
"Quebec",1819,302,"CA","en"
"Reunion",262,647,"RE","fr"
"Romania",40,226,"RO","ro"
"Russia",7,250,"RU","ru"
"Rwanda",250,635,"RW","rw"
"Saint-Barthelemy",590,340,"BL","fr"
"Saint Helena",290,658,"SH","en"
"Saint Kitts and Nevis",1869,"356","KN","en"
"Saint Lucia",1758,"358","LC","en"
"Saint Martin (French side)",590,340, "MF","fr"
"Saint Pierre and Miquelon",508,308,"PM","fr"
"Saint Vincent and the Grenadines",1670,"360","VC","en"
"Samoa",685,549,"WS","sm"
"Sao Tome and Principe",239,626,"ST","pt"
"Saskatchewan",1306,302,"CA","en"
"Saudi Arabia",966,420,"SA","ar"
"Senegal",221,608,"SN","wo"
"Serbia",381,220,"RS","sr"
"Seychelles",248,633,"SC","fr"
"Sierra Leone",232,619,"SL","en"
"Singapore",65,525,"SG","en"
"Slovakia",421,231,"SK","sk"
"Slovenia",386,293,"SI","sl"
"Solomon Islands",677,540,"SB","en"
"Somalia",252,637,"SO","so"
"South Africa",27,655,"ZA","xh"
"South Korea",82,450,"KR","ko"
"South Sudan",211,659,"SS","en"
"Spain",34,214,"ES","es"
"Sri Lanka",94,413,"LK","si"
"Sudan",249,634,"SD","ar"
"Suriname",597,746,"SR","nl"
"Swaziland",268,653,"SZ","ss"
"Sweden",46,240,"SE","sv"
"Switzerland",41,228,"CH","de"
"Syria",963,417,"SY","ar"
"Taiwan",886,466,"TW","cmn"
"Tajikistan",992,436,"TJ","tg"
"Tanzania",255,640,"TZ","sw"
"Thailand",66,520,"TH","th"
"Togo",228,615,"TG","fr"
"Tokelau",690,690,"TK","tkl"
"Tonga",676,539,"TO","to"
"Trinidad and Tobago",1868,"374","TT","en"
"Tunisia",216,605,"TN","ar"
"Turkey",90,286,"TR","tr"
"Turkmenistan",993,438,"TM","tk"
"Turks and Caicos Islands",1649,"376","TC","en"
"Tuvalu",688,553,"TV","tvl"
"Uganda",256,641,"UG","sw"
"Ukraine",380,255,"UA","uk"
"United Arab Emirates",971,"424|430|431","AE","ar"
"United Kingdom",44,"234|235","GB","en"
"United States of America",1,"310|311|312|313|314|315|316","US","en"
"Uruguay",598,748,"UY","es"
"Uzbekistan",998,434,"UZ","uz"
"Vanuatu",678,541,"VU","bi"
"Venezuela",58,734,"VE","es"
"Vietnam",84,452,"VN","vi"
"U.S. Virgin Islands",1340,"332","VI","en"
"Wallis and Futuna",681,543,"WF","fr"
"West Bank",970,0,"PS","ar"
"Yemen",967,421,"YE","ar"
"Zambia",260,645,"ZM","en"
"Zimbabwe",263,648,"ZW","en"
Loading