Curl responses in php
Curl responses in php
Curl responses in php
When curl gives success response
$result = curl_exec($curl);
$response = json_decode($result, true);
When curl gives error, and one have to find out the exact errors
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
When one have to find the response code
$result = curl_exec($curl);
$response = json_decode($result, true);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($httpcode == '401'){
echo "window.location.href = '#';";
}else{
return $response;
}
0 Comment's
Add Comment
Register to Reply
Login
Register