Php 谷歌不支持https,但它支持http
我正在使用google的api发送推送通知,问题是如果我使用“”,它工作得很好,但是如果我使用 “”(使用http上的S)它不工作,卷曲停止 有人知道为什么吗Php 谷歌不支持https,但它支持http,php,http,curl,https,google-cloud-messaging,Php,Http,Curl,Https,Google Cloud Messaging,我正在使用google的api发送推送通知,问题是如果我使用“”,它工作得很好,但是如果我使用 “”(使用http上的S)它不工作,卷曲停止 有人知道为什么吗 $headers = array('Authorization:key=' . $apiKey); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://android.googleapis.com/gcm/send"); if ($headers) curl_setopt($
$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);
我在这两种情况下都得到了回应:
<?php
ini_set('display_errors', true);
error_reporting(-1);
function o($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization:key=123']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [1,2,3]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
var_dump( o("http://android.googleapis.com/gcm/send") );
var_dump( o("https://android.googleapis.com/gcm/send") );
它不工作,卷曲停止。
1/它怎么不工作?问题/错误是什么?2/卷曲如何停止?回声“这是可见的”$响应=curl_exec($ch);回声“这是不可见的”;当我使用https时,它只显示“this is visible”,而当我使用http时,它显示两个文本打开错误报告或查看错误日志以查看问题。您有任何错误吗?写入ini\u集('display\u errors',true);错误报告(-1)如果您有任何错误,请向我们报告。我得到的唯一错误是变量为空,但仍然只有1个响应如果您将我的代码保存在some.php
文件中并运行它,@D4rWiNS:你还是有错误吗?@D4rWiNS:有什么问题吗?我们仍然不知道我在家里使用的脚本是否有效,但如果我在工作中使用它,它就不起作用了,所以它似乎是服务器配置中的某个东西。我告诉了我的老板,他给我们的服务器经理发了一张罚单