how to send data to php webservice using GET method in JSON Format in C# -


i new webservice, , trying send json data .php webservice wp7 application created in vs2010. have used uploadstringasync method, method not working method. throwing exception while using method. please help.

below c# code

webclient postwithparamsclient = new webclient();  postwithparamsclient.headers["content-type"] = "application/json"; postwithparamsclient.uploadstringcompleted += new uploadstringcompletedeventhandler(postwithparamsclient_uploadstringcompleted);  postwithparamsclient.uploadstringasync(url, "post", "{ \"latitude\": " + textbox2.text.tostring() + ", \"longitude\": " + textbox3.text.tostring() + " }"); 

below webservice

<?php /*xml format <gpstrack>     <latitude>30°n</latitude>     <longitude>38°n</longitude>     <mobtime>mobiletime</mobtime> </gpstrack> xml format*/  $xml = file_get_contents('php://input'); $finalarray = json_decode(json_encode((array) simplexml_load_string($xml)),1); //$finalarray=array('latitude'=>'12.1','longitude'=>'3.2','mobtime'=>'325695142');  $newfb = new table($db,"gpslog","track_id"); $newfb -> latitude              = $finalarray['latitude']; $newfb -> longitude             = $finalarray['longitude']; $newfb -> mobtime               = strtotime($finalarray['mobtime']);  $newfb -> insert();  print "success";  exit; ?> 

to use method, u'v use downloadstringasync instead.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -