Php curl error show curl exec, show curl error or success code
$data_json = json_encode($data_json);
$cha = curl_init();
curl_setopt($cha, CURLOPT_URL, $url);
curl_setopt($cha, CURLOPT_POST, true);
curl_setopt($cha, CURLOPT_POSTFIELDS, $data_json);
curl_setopt(
$cha,
CURLOPT_HTTPHEADER,
array(
"Content-Type: application/json",
"Authorization: Bearer ".$accessToken,
"Content-length: " . strlen($data_json),
"Host: graph.microsoft.com",
)
);
curl_setopt($cha, CURLOPT_FAILONERROR, true);
curl_setopt($cha, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($cha);
if(curl_exec($cha) === false)
{
echo 'Curl error: ' . curl_error($cha);
}
else
{
echo 'Operation completed without any errors';
}