I am trying to write a PHP script that post username and password as JSON object to a server and in response get a JSON object that contains UserId and token in JSON.
Following is my code
if (isset($_GET["user"]) && isset($_GET["key"])){ $username = $_GET["user"]; $pass = $_GET["key"]; $data = array("username" => $username, "password" => $pass); $data_string = json_encode($data); echo $data_string; $ch = curl_init('https://sce15.appspot.com/api/g_usrs/signin'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $response = curl_exec($ch); curl_close($ch); $usr = json_decode($response, true); echo $usr; } else{ echo "Oops Something went wrong: Error 1"; } But I am not getting anything in output, my browser window is white blank. I am not able to figure out the mistake. I am able to get JSON object when using javascript for the same URL, but I need to do it with PHP.
Any help is appreciated. Thanks
echo $data_string;doesn't print anything?