使用 c2dm 一次发送多个推送
有没有办法一次发送多条推送消息?
昨天发送100条消息花了38秒,太长了。
我只获得一次身份验证令牌,我使用:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://android.apis.google.com/c2dm/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: GoogleLogin auth=$authCode"));
$post_fields = "registration_id=" . urlencode($deviceToken)
. "&".$payload
. "&collapse_key=$key";
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($ch);
curl_close($ch);
if (strpos($response, '200 OK') !== false) {
return true;
}
else echo $response." ";
return false;
对于我获得的每个推送令牌。
有更快的方法吗?
谢谢
Is there a way to send many pushes message at one time ?
Yesterday it tooks 38 second to send 100 messages, it's way too long.
I get the auth token only one time, the I use:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://android.apis.google.com/c2dm/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: GoogleLogin auth=$authCode"));
$post_fields = "registration_id=" . urlencode($deviceToken)
. "&".$payload
. "&collapse_key=$key";
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($ch);
curl_close($ch);
if (strpos($response, '200 OK') !== false) {
return true;
}
else echo $response." ";
return false;
for each push token I got.
Is there a faster way ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
curl_multi_exec 就是答案。
curl_multi_exec is the answer.