I am trying to send a url from a php page to a json page in the format
"http://myserver.com/login?q={"myid":"phill","password":"mypass"}"
. If I paste this into a browser address it works correctly. I have tried HttpRequest and cURL with no success. Can you suggest how this may be achieved?.
<?php
$yourJSONEncodedData = array('userid' => "phill", 'password' => "mypassword");
$url = "http://myserver.com/login?q=".json_encode($yourJSONEncodedData);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$output = curl_exec($curl);
curl_close($curl);
var_dump($output);
$response = json_decode($output,true);
echo $response;
?>
I am expecting "{}" to be returned to the php program.