我在通过CURL通知发送给19k用户时遇到了问题。
新的FB应用程序通知API是goldmine,所以我在我的应用程序中实现了一个系统,当他的朋友得分高于他时通知玩家。 问题是该应用程序必须通过卷曲发送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]; }
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; }
第一个函数接受app令牌并使用它通过第二个函数(curl)发送通知。
foreach用户已经安装了app并且必须通知我应用这两个功能。 问题是第二个功能持续约3秒/用户
感谢
LATER EDIT:api批量发送是答案:),可以一次发送最多50个通知