【发布时间】:2013-08-18 18:37:01
【问题描述】:
我正在使用 google 的 api 发送推送通知,问题是如果我使用“http://android.googleapis.com/gcm/send”它会完美,但如果我使用 “https://android.googleapis.com/gcm/send”(http 上带有 S)它不起作用并且 curl 停止。
有人知道为什么吗?
$headers = array('Authorization:key=' . $apiKey);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"http://android.googleapis.com/gcm/send");
if ($headers)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
【问题讨论】:
-
It doesnt work and the curl stop.1/ 怎么不工作?问题/错误是什么? 2/ CURL 是如何停止的? -
echo "这是可见的"; $response = curl_exec($ch); echo "这是不可见的";当我使用https时,它只显示“这是可见的”,仅此而已,当我使用http时,它显示两个文本
-
要么打开错误报告,要么查看错误日志以查看问题。
标签: php http curl https google-cloud-messaging