I'am sending JSON data to an URL and then I also recieve JSON.
I'm using PHP CURL to recieve the data and show it on my page.
My Problem is that I can only get the json completely and I can't show only a selected value from that JSON data.
I got this already:
//API Url
$url = "https://auth.unilinxx.com/test";
//Initiate cURL.
$ch = curl_init($url);
//The JSON data.
$jsonData = array("value" => "Gideon lol");
//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
//Execute the request
$result = curl_exec($ch);
$values = json_decode($result, true);
echo $values["value"];
My result is: {"value":"U heeft Gideon lol gestuurd."}
I like to have only this: U heeft Gideon lol gestuurd.
How can I do that?