如何使用php发送facebook应用程序生成的请求?

如何使用php发送facebook应用程序生成的请求?,php,facebook-graph-api,facebook-php-sdk,Php,Facebook Graph Api,Facebook Php Sdk,我使用以下url向用户发送应用程序生成的请求: “$userid.”&message=Hello&access_-token=“.$appToken.”&method=post 如果$userid设置为当前登录用户,则此操作正常。但我无法向我的应用程序用户朋友发送请求,上述代码引发以下错误: {“error”:{“message”:(#2)无法创建任何应用程序请求”,“type”:“OAutheException”,“code”:2}}这对我来说很有效: $app_id = YOUR_APP_I

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

“$userid.”&message=Hello&access_-token=“.$appToken.”&method=post

如果$userid设置为当前登录用户,则此操作正常。但我无法向我的应用程序用户朋友发送请求,上述代码引发以下错误:

{“error”:{“message”:(#2)无法创建任何应用程序请求”,“type”:“OAutheException”,“code”: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; $app\u id=您的app\u id; $app\u secret=您的app\u secret; $token_url=”https://graph.facebook.com/oauth/access_token?" . “客户_id=”$应用程序id。 “&client_secret=”$你的秘密。 “&授予\类型=客户端\凭据”; //您的应用程序访问令牌 $app\u access\u token=file\u get\u contents($token\u url); $apprequest_url=”https://graph.facebook.com/" . $your_friend_id。 “/apprequests?message='some message'&”。 $app\u access\u令牌。“&method=post”; $result=file\u get\u contents($apprequest\u url); 回声$结果; 希望能有帮助