我使用以下网址向用户发送应用生成的请求:
https://graph.facebook.com/apprequests/?ids= “$用户ID。 ”&安培;消息=你好&安培; =的access_token&安培“ $ APPTOKEN。”;方法=交
如果将$ userid设置为当前登录用户,则此方法正常。但我无法向作为应用程序用户的朋友发送请求,上述代码会引发以下错误:
{“error”:{“message”:“(#2)无法创建任何应用请求”,“输入”:“OAuthException”,“code”:2}}
答案 0 :(得分:2)
这对我有用:
$app_id = YOUR_APP_ID; $app_secret = YOUR_APP_SECRET; $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&client_secret=" . $app_secret . "&grant_type=client_credentials"; //your app access token $app_access_token = file_get_contents($token_url); $apprequest_url ="https://graph.facebook.com/" . $your_friend_id . "/apprequests?message='some message'&" . $app_access_token . "&method=post"; $result = file_get_contents($apprequest_url); echo $result;
希望有所帮助