Facebook 向19k用户发送的新FB通知API 1:1

Facebook 向19k用户发送的新FB通知API 1:1,facebook,notifications,Facebook,Notifications,我无法通过CURL向19k用户发送通知 新的FB应用程序通知API是goldmine,因此我在我的应用程序中实现了一个系统,当玩家的朋友得分高于他时,该系统会通知玩家。 问题是,该应用程序必须通过curl发送19k个通知,这需要大约950个小时。 是否有更快的解决方案发送这些证书?我的意思是,我已经看到大多数大玩家(如zynga)都成功地使用了应用程序通知,我不认为他们发送的通知比我少:) 这是我的密码 function _getAppToken(){ $APPLICAT

我无法通过CURL向19k用户发送通知

新的FB应用程序通知API是goldmine,因此我在我的应用程序中实现了一个系统,当玩家的朋友得分高于他时,该系统会通知玩家。 问题是,该应用程序必须通过curl发送19k个通知,这需要大约950个小时。 是否有更快的解决方案发送这些证书?我的意思是,我已经看到大多数大玩家(如zynga)都成功地使用了应用程序通知,我不认为他们发送的通知比我少:)

这是我的密码

function _getAppToken(){ $APPLICATION_ID = "xxxxxxx"; $APPLICATION_SECRET = "xxxxxxxx"; $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $APPLICATION_ID . "&client_secret=" . $APPLICATION_SECRET . "&grant_type=client_credentials"; //$app_token = file_get_contents($token_url); $accessToken = explode('=', file_get_contents($token_url)); return $accessToken[1]; } 函数_getAppToken(){ $APPLICATION\u ID=“xxxxxxx”; $APPLICATION\u SECRET=“xxxxxxxx”; $token_url=”https://graph.facebook.com/oauth/access_token?" . “client_id=”.$APPLICATION_id。 “&client_secret=”.$APPLICATION_secret。 “&授予\类型=客户端\凭据”; //$app\u token=file\u get\u contents($token\u url); $accessToken=explode('=',file_get_contents($token_url)); 返回$accessToken[1]; } 函数_curlDoNotifications($fb_id,$tokennn,$mesaj,$hrf='') { $attachment=array( “访问令牌”=>$tokennn, 'href'=>$hrf, “模板”=>$mesaj ); $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,'https://graph.facebook.com/“.$fb_id./notifications”); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$attachment); curl_setopt($ch,CURLOPT_RETURNTRANSFER,false);//抑制curl输出 $result=curl\u exec($ch); 卷曲关闭($ch); 返回$result; } 第一个函数获取app令牌,并使用它通过第二个函数(curl)发送通知

对于每个安装了应用程序且必须得到通知的用户,我应用了这两个功能。 问题是,第二个功能持续约3秒/用户

谢谢


稍后编辑:api批量发送是答案:)一次最多可以发送50个通知

19K用户,“金矿”…这闻起来有点垃圾味。无论如何,为了加快速度,你可以使用批处理请求——这些请求可以减少必要的HTTP请求数量,从而减少发送通知所需的总时间。不,这根本不是垃圾邮件。我会通知得分比他低的用户朋友。该应用程序实际拥有24万用户实际上,批处理工作得很好(与php守护进程绑定)=>即时1:1通知 function _curlDoNotifications($fb_id, $tokennn, $mesaj, $hrf = '') { $attachment = array( 'access_token' => $tokennn, 'href' => $hrf, 'template' => $mesaj ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/' . $fb_id . '/notifications'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); //to suppress the curl output $result = curl_exec($ch); curl_close($ch); return $result; }