Forum Discussion

coderafg's avatar
coderafg
New Contributor
5 years ago

RestAPI Get data base on id. How to connect using PHP curl.

$licensePlate = urlencode($_GET['licensePlate']);

$client_id = urlencode("atsjD1ESjQAc1CgYssWf3n7Ulk5s4U06");
$client_secret = urlencode("MTGjsSVkT6R4dz1L");

 

//next example will recieve all messages for specific conversation
$service_url = file_get_contents("https://stage.apigw.cdkapps.eu/sample/sample/v1/repair-orders?licensePlate=$licensePlate");

$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
$info = curl_getinfo($curl);
curl_close($curl);
die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($curl_response);
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
die('error occured: ' . $decoded->response->errormessage);
}
echo 'response ok!';
var_export($decoded->response);

No RepliesBe the first to reply