Private Static string getownpublicip () {try {var html = new WebClient (). downloadstring ("http://checkip.dyndns.com/"); var ipstart = html. indexof (":", stringcomparison. ordinalignorecase) + 2; return HTML. substring (ipstart, HTML. indexof ("</", ipstart, stringcomparison. ordinalignorecase)-ipstart ). trim ();} catch (system. exception ex) {system. diagnostics. debug. writeline (ex. tostring (); Return St Ring. Empty;} public static locationresponsedata getownlocation () {try {string url = string. Format ("http://api.ipinfodb.com/v3/ip-city? Key = {0} & IP = {1} & format = {2} "," response ", getownpublicip ()," JSON "); string response = webutilities. gethttprequest (URL); If (response = NULL) return NULL; return jsonutilities. jsontoobj <locationresponsedata> (response);} catch (system. exception ex) {system. diagnostics. debug. writeline (ex. tostring (); return NULL;} public class locationresponsedata {Public String statuscode {Get; set;} Public String statusmessage {Get; set;} Public String IPaddress {Get; set;} Public String countrycode {Get; set;} Public String countryname {Get; set;} Public String regionname {Get; set;} Public String cityname {Get; set ;} public String zipcode {Get; set;} public double latitude {Get; set;} public double longpolling {Get; set;} Public String timezone {Get; Set ;}}