gpt4 book ai didi

php - curl :未知的 SSL 协议(protocol)错误 gcm

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:29 25 4
gpt4 key购买 nike

enter image description here我在 php(MAMP) 中设计了 gcm 服务器。 curl version-7.43.0,php version 7.0.0 .服务器代码-

<?php



function send_push_notification($registration_id,$message){
define('API_KEY','AIzaSyAoFih8qEFlOis3vVWhsxxlLxxxxxxxxxx');
$url='https://gcm-http.googleapis.com/gcm/send';

$fields=array(
'registration_id'=>$registration_id,
'data'=>$message,
);
$headers=array(
'Authorization:key='.API_KEY,
'Content-Type:application/json'
);

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);



$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}

// Close connection
curl_close($ch);
echo $result;
}



?>
<?php
send_push_notification("e2DgrsZPGKU:APA91bF_73a6-o5CLV-gdcZzYFAbtikJqi-5w6gDSCaRa4z8-1iGLeV5SS6hQkW8pj_g_DxBe7JLDsOPMGu3y1GkKw1vpn_ZEWIeCwbSITpd0pLwaz50W8uzHKNghvnf1xxxxxxxxxxx","hi");
?>

当我尝试在我的浏览器中运行此 php 脚本时,它显示以下错误

Curl failed: Unknown SSL protocol error in connection to gcm-http.googleapis.com:443

我已禁用 SSL 验证,但它仍然显示 curl 错误。

最佳答案

将 SSL 版本更改为 6 对我有用。

curl_setopt($ch,CURLOPT_SSLVERSION,6);

关于php - curl :未知的 SSL 协议(protocol)错误 gcm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35238153/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com