Skip to content

Instantly share code, notes, and snippets.

@unwiredlabs
Last active November 27, 2023 18:48
Show Gist options
  • Select an option

  • Save unwiredlabs/9543100 to your computer and use it in GitHub Desktop.

Select an option

Save unwiredlabs/9543100 to your computer and use it in GitHub Desktop.

Revisions

  1. locationapi revised this gist Jul 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ public static void GetNearest(string key, string mcc, string mnc, string lac, st
    {
    try
    {
    string url = "http://us1.uwiredlabs.com/v2/process.php";
    string url = "http://us1.unwiredlabs.com/v2/process.php";
    var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    httpWebRequest.ContentType = "application/json; charset=utf-8";
    httpWebRequest.Method = "POST";
  2. locationapi revised this gist Jul 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ public static void GetNearest(string key, string mcc, string mnc, string lac, st
    {
    try
    {
    string url = "http://uus1.nwiredlabs.com/v2/process.php";
    string url = "http://us1.uwiredlabs.com/v2/process.php";
    var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    httpWebRequest.ContentType = "application/json; charset=utf-8";
    httpWebRequest.Method = "POST";
  3. locationapi revised this gist Jul 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ public static void GetNearest(string key, string mcc, string mnc, string lac, st
    {
    try
    {
    string url = "http://unwiredlabs.com/v2/process.php";
    string url = "http://uus1.nwiredlabs.com/v2/process.php";
    var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    httpWebRequest.ContentType = "application/json; charset=utf-8";
    httpWebRequest.Method = "POST";
  4. locationapi revised this gist Mar 14, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    ///Contributed by Stuart Eastland of RightFile.com
    ///
    ///

    public static void GetNearest(string key, string mcc, string mnc, string lac, string cid)
    {
    try
  5. locationapi revised this gist Mar 14, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    ///Contributed by Stuart Eastland of RightFile.com
    ///
    ///
    public static void GetNearest(string key, string mcc, string mnc, string lac, string cid)
    {
    try
  6. locationapi created this gist Mar 14, 2014.
    44 changes: 44 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    public static void GetNearest(string key, string mcc, string mnc, string lac, string cid)
    {
    try
    {
    string url = "http://unwiredlabs.com/v2/process.php";
    var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    httpWebRequest.ContentType = "application/json; charset=utf-8";
    httpWebRequest.Method = "POST";

    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
    {
    string json = string.Format("{{ \"token\": \"{0}\", \"radio\": \"gsm\", \"mcc\": {1}, \"mnc\": {2}, \"cells\": [{{ \"lac\": {3}, \"cid\": {4} }}] }}", key, mcc, mnc, lac, cid);

    streamWriter.Write(json);
    streamWriter.Flush();
    }

    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
    string json = streamReader.ReadToEnd();

    var results = JsonConvert.DeserializeObject<dynamic>(json);
    var status = results.status.Value;

    if (status == "ok")
    {
    var balance = results.balance.Value;
    var lat = results.lat.Value;
    var lon = results.lon.Value;
    var accuracy = results.accuracy.Value;

    }
    else
    {
    var message = results.message.Value;
    }
    }
    }
    catch (Exception ex)
    {
    // handle exception
    }
    }