json - PHP Send post data to URL and get response from that webpage -


Is it possible to send postal data to a URL and receive a response from that webpage, it is in JSON, and Use it for something different if this is possible, then how?

thanks :)

Edit: I have to send to another PHP script on another server, but I have to get the answer from that script and use it in my script The data sent by another is in JSON, but it is no longer a problem.

Using the php curl you can get it as the following

  1, 'name' = & gt; 'test'); // parameter $ params = json_encode ($ aParameter) to send; Optionally change the option to send the Jason String // header to the // parameter if there is no header, leave it and remove the curlopt_httpheader object from the curl call $ aHeaders = array ('Client-secret' = & gt; 'Xxxxx', 'authorization' => 'xxxxxx', 'content-type' = & gt; 'content-type: application / jason', 'accept' = & gt; 'acceptance: application / jsan'); $ C = curl_init (); Curl_setopt ($ c, CURLOPT_USERAGENT, 'Mozilla / 5.0 (X11; Ubuntu; Linux x86_64; rv: 11.0) Gecko / 20100101 Firefox / 11.0'); // Blank user agents may not have been accepted. Curl_setopt ($ c, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ c, CURLOPT_FOLLOWLOCATION, 1); Curl_setopt ($ c, CURLOPT_AUTOREFERER, 1); Curl_setopt ($ c, CURLOPT_SSL_VERIFYPEER, 0); Curl_setopt ($ c, CURLOPT_HTTPHEADER, $ aHeaders); Curl_setopt ($ c, CURLOPT_URL, $ url); Curl_setopt ($ c, CURLOPT_REFERER, $ url); Curl_setopt ($ c, CURLOPT_POST, true); Curl_setopt ($ C, CURLOPT_POSTFIELDS, $ parameter); $ SResponse [$ key] = curl_exec ($ c);  

Comments