To get more info regarding the error, you can use below code.
$responseInfo = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$responseHeader = substr($result, 0, $header_size);
$responseBody = substr($result, $header_size);
echo 'Header: <br>'. $responseHeader;
echo 'Body: <br>'. $responseBody;
Please check this
$responseInfo['http_code'] -> gives the http response code.
Or
If you are not sure how to debug, then please use some libraries which would help you.
ZendService_Google_Gcm
Quick reference of gcm response codes
You can handle like this
https://github.com/zendframework/ZendService_Google_Gcm/blob/master/library/ZendService/Google/Gcm/Client.php#L116
3
solved Curl is not giving response in PHP [duplicate]