I have a code which should fetch courseID from JSON response obtained , But currently it is not fetching anything . It shows me the entire response and not one . can someone help me with this .
JSON response obtained.
{
"results": [
{
"CourseID": "ASPO",
"Success": "Yes"
}
]
}
i just want to retrieve the CourseID.
and below is my code
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://AbC:3939');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "ABC=AE");
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Authorization: Bearer hjhjhjhjhjhj338sj';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch) ;
}else{
$result_value = json_decode($result);
print_r($result_value->results[0]->CourseID);
}
curl_close($ch);
?>