3

I have been porting albums in to websites with the below code and it has suddenly stopped working. The albums and photos are public but it seems to want an access_token.

Here is the graph for this particular album:

https://graph.facebook.com/483171821709416/photos

Here is the javascript I've been using:

$.getJSON('//graph.facebook.com/483171821709416/photos?callback=?',function(json){
$.each(json.data,function(){
$('<li></li>')  
.append('<span class="thumb" style="background: url(' + this.images[1].source + ') center no-repeat; background-size: 140%;"><a href=' + this.images[0].source + ' rel="gallery"></a></span>')
.appendTo('#album-gallery');
});
});
Kirk Ross
  • 6,413
  • 13
  • 61
  • 104
  • Maybe this is by design. Take a look at this similar question: http://stackoverflow.com/questions/7633234/get-public-page-statuses-using-facebook-graph-api-without-access-token – Mindbreaker May 02 '13 at 23:15
  • I am currently digesting this similar answer http://stackoverflow.com/questions/16346603/facebook-graph-will-not-let-me-access-any-photo-albums-from-a-public-group – Matthew Lock May 03 '13 at 09:05
  • Would anyone know how to modify code to grab photos from a directory on my own server rather that Facebook? I'm trying to salvage 50+ galleries that use that code and would love to not have to completely rewrite each html page. – Kirk Ross May 05 '13 at 18:48

1 Answers1

1

Assuming you own these photos, and they are indeed public, all you will need is to produce a page access token, which has no expiry. Creating an app is just clicking a button, and setting a domain, no actual coding is needed. Then you go through this scenario

When a user grants an app the manage_pages permission, the app is able to obtain page access tokens for pages that the user administers by querying the [User ID]/accounts Graph API endpoint. With the migration enabled, when using a short-lived user access token to query this endpoint, the page access tokens obtained are short-lived as well.

Exchange the short-lived user access token for a long-lived access token using the endpoint and steps explained earlier. By using a long-lived user access token, querying the [User ID]/accounts endpoint will now provide page access tokens that do not expire for pages that a user manages. This will also apply when querying with a non-expiring user access token obtained through the deprecated offline_access permission.

https://graph.facebook.com/oauth/access_token?             
    client_id=APP_ID&
    client_secret=APP_SECRET&
    grant_type=fb_exchange_token&
    fb_exchange_token=EXISTING_ACCESS_TOKEN 
phwd
  • 19,975
  • 5
  • 50
  • 78