To implement a post JSON data on the Android/java platform:
JsonobjectJsonobj= New Jsonobject();Jsonobj.Put("Username",Username);Jsonobj.Put("Apikey",Apikey);Create the POST object and add the parametersHttpPostHttpPost= New HttpPost(Url);StringentityEntity= New Stringentity(Jsonobj.Tostring(),HTTP.utf_8); entity.. Setentityentityhttpclient client = new defaulthttpclient (); httpresponse response = client execute (httppost
Use Curl to execute the following command:
Curl-l-H "Content-type:application/json"-X post-d ' {"Phone": "13521389587", "Password": "Test"} ' http://domain/apis/ Users.json
With jquery:
$ajax ({ Url:url, Type: "POST" Data:data,: "Application/json; Charset=utf-8 ", Datatype:" JSON " , Success: function< Span class= "pun" > () { ... }}) /span>
PHP is implemented with Curl:
1 $data=Array("Name" = "Hagrid", "Age" = "36"); 2 $data _string= Json_encode ($data); 3 $ch= Curl_init (' http://api.local/rest/users '); 4curl_setopt ($ch, Curlopt_customrequest, "POST"); 5curl_setopt ($ch, Curlopt_postfields,$data _string);6curl_setopt ($ch, Curlopt_returntransfer,true);7curl_setopt ($ch, Curlopt_httpheader,Array( 8' Content-type:application/json ',9' Content-length: '.strlen($data _string)) Ten ); One $result= Curl_exec ($ch);
How to post a JSON-formatted data to a restful service