sending multiple push at one time with c2dm
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
curl_multi_exec is the answer.
精彩评论