簡體   English   中英

Google不適用於https,但適用於http

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM