Facebook 照片上传错误

发布于 2024-11-26 03:11:18 字数 918 浏览 0 评论 0原文

您好,我正在尝试编写一个 Facebook 应用程序,将照片发布到用户页面。我已经逐字逐句地遵循了这个教程

但每当我尝试上传照片时,我都会收到此错误:

{
   "error": {
      "type": "OAuthException",
      "message": "A user access token is required to request this resource."
   }
}

我相信问题来自此代码,因为我正在发送 AppID、AppSecret 和 post_login_url (均已正确填充),但是 $response 完全空白:

   $token_url= "https://graph.facebook.com/oauth/"
         . "access_token?"
         . "client_id=" .  $app_id 
         . "&redirect_uri=" . urlencode( $post_login_url)
         . "&client_secret=" . $app_secret
         . "&code=" . $code;
         $response = file_get_contents($token_url);
         $params = null;
         parse_str($response, $params);
         $access_token = $params['access_token'];

任何帮助都会不胜感激,一如既往,我的截止日期很紧,

谢谢,

道格

Hi Im trying to write a facebook application that will post a photo to a users page. Ive pretty much word for word followed this tutorial.

but whenever I try and upload a photo I get this error:

{
   "error": {
      "type": "OAuthException",
      "message": "A user access token is required to request this resource."
   }
}

I beleive the problem is coming from this code as I'm sending the AppID, AppSecret and post_login_url (which are all correctly populated) however $response is completely blank:

   $token_url= "https://graph.facebook.com/oauth/"
         . "access_token?"
         . "client_id=" .  $app_id 
         . "&redirect_uri=" . urlencode( $post_login_url)
         . "&client_secret=" . $app_secret
         . "&code=" . $code;
         $response = file_get_contents($token_url);
         $params = null;
         parse_str($response, $params);
         $access_token = $params['access_token'];

Any help would be appreciated, as always im on a tight deadline

Thanks,

Doug

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

(り薆情海 2024-12-03 03:11:18

应用程序访问令牌用于代表应用程序进行 API 调用,您的根本问题可能是您尝试进行的 API 调用必须代表用户进行,并且需要用户访问令牌时生成的用户访问令牌授权您的应用程序。
您上面的代码应该可以很好地获取应用程序访问令牌

The Application Access token is used to make API calls on behalf of an app, your underlying issue is likely that the API call you're trying to make has to be made on behalf of a User and needs a user access token produced when a user authorises your app.
The code you have above should be fine for getting an App Access token

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文