最近推播遇到一个问题
同一组API_KEY跟同一组RID
有时连续发送会有一部分成功送出
但也有一部分会呈现失败
失败原因会显示
string(147) "<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
这讯息是说API KEY不正确
是常态问题?还是程式问题??
完整程式如下
>>>>>前面参数略过
$message = array("message" => $message);
$url = 'https://android.googleapis.com/gcm/send';
$json = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
$headers = array(
'Authorization: key=' . $API_KEY,
'Content-Type: application/json'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //忽略SSL验证
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json));
$result = curl_exec($curl);
curl_close($curl);
跪求高手们指导指导小弟,感恩