1

我正在使用以下 url 向用户发送应用程序生成的请求:

https://graph.facebook.com/apprequests/?ids= ".$userid."&message=Hello&access_token=".$appToken."&method=post

如果 $userid 设置为当前登录用户,这将正常工作。但是我无法向我的应用程序用户朋友发送请求,并且上面的代码会引发以下错误:

{"error":{"message":"(#2) 无法创建任何应用请求","type":"OAuthException","code":2}}

4

1 回答 1

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";

//你的应用访问令牌
$app_access_token = file_get_contents($token_url);

$apprequest_url =“https://graph.facebook.com/”。
$your_friend_id 。
"/apprequests?message='一些消息'&" .
$app_access_token 。"&method=post";

$result = file_get_contents($apprequest_url);
回显$结果;

希望能帮助到你

于 2012-04-25T04:54:48.577 回答