本文介绍了“请求此资源需要访问令牌"使用 Facebook php sdk 访问相册/照片时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 php sdk 访问网站中用户的相册和照片.我可以登录,还可以检索有关相册和照片的所有信息.

I am using the php sdk to access a user's albums and photos in a website.I am able to login and also able to retrieve all the info about the albums and photos.

但是,我无法在网页上显示这些照片.

However, I am not able to display these photos on the webpage.

当我尝试图形 API 时,得到如下照片/相册:

When I try the graph API, to get the photo / album like below:

https://graph.facebook.com/131833353530147/picture

我收到以下错误消息:

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

但是当我尝试显示我的个人资料图片并且我确实有一个有效的访问令牌时也是如此.

But the same is working in while I try to display my profile pic and I do have a valid access token.

对此的帮助将不胜感激.

Help on this would be greatly appreciated.

推荐答案

您需要三样东西.

  1. 您需要与这些照片的所有者进行 oAuth.(具有user_photos"扩展权限)

  1. You need to oAuth with the owner of those photos. (with the 'user_photos' extended permission)

您需要访问令牌(oAuth 完成后,您会在 URL 框中返回该令牌.)

You need the access token (which you get returned in the URL box after the oAuth is done.)

完成后,您可以像这样访问照片https://graph.facebook.com/me?access_token=ACCESS_TOKEN

When those are complete you can then access the photos like so https://graph.facebook.com/me?access_token=ACCESS_TOKEN

您可以在此处找到更详细的所有信息:http://developers.facebook.com/文档/身份验证

You can find all of the information in more detail here: http://developers.facebook.com/docs/authentication

这篇关于“请求此资源需要访问令牌"使用 Facebook php sdk 访问相册/照片时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:49