"An access token is required to request this resource" while accessing an album / photo with Facebook php sdk

Alloi picture Alloi · Nov 8, 2010 · Viewed 124.4k times · Source

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.

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

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

I get the following error message:

{
   "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.

Answer

jwmann picture jwmann · Jan 31, 2011

There are 3 things you need.

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

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

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

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