![](/img/trans.png)
[英]Rewrite from http to https with .htaccess doesnt work on strato.de
[英]Google doesnt work on https but it work on http
我正在使用Google的api来发送推送通知,问题是如果我使用“ http://android.googleapis.com/gcm/send ”,它可以完美运行,但是如果我使用“ https://android.googleapis。 com / gcm / send “(在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($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") );
因此,您可能在某处出错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.