Facebook Graph will not let me access any photo al

2019-07-17 05:57发布

问题:

I am having a bit of trouble grabbing photos from a public album from the group 'WirralGSB' - I set the website up in October originally and it was fine until a couple of days ago. I think the issue lies in that I do not have an access key. I made an access key through an app that I made but these were only valid for 30 minutes or so and then they expired and the website no longer displays the images. The website is: http://wirralgrammarboys.com/news/109 this page --should-- contain a facebook album but doesn't. Is there a way of me generating an access key that will not expire? You should also probably know that I am not an administrator of the group, just a 'normal' member, although I can instruct the admin to make changes if necessary.

The code I'm using in the function is:

var graph = "https://graph.facebook.com/<?php echo $row[ALBUMID]; ?>"
+ "/photos?limit=20" + "&access_token=CAACNTB50S2IBAIzMYWdNsNFSVAPbkUgQKm1TGX6kNzlIDvQr2BLUKURdZBMqaZBmLLWKhZC8kE9Qcet4UMvq5ZAwDLaSf36d1jZAaBbyAtA0ze6HiI5jfKXjLxLT1sl0ZCdZCydlZCFMdIZCTZAEQ59GxOpNVSiQDkgXEZD";

Until the other day I did not have an 'access_token' variable, it ended at the limit line and it worked fine without any issues.

Thanks in anticipation, this has been bugging me for days!

Cobain.

回答1:

You can use an extended page access token which will not expire.

Apps can retrieve a Page access token from Page admin users when they authenticate with the manage_pages permission. If the user access token used to retrieve this Page access token is short-lived, the Page access token will also be short-lived.

To get a longer-lived Page access token, exchange the User access token for a long-lived one, as above, and then request the Page token. The resulting Page access token will not have any expiry time.

https://developers.facebook.com/docs/facebook-login/access-tokens/



回答2:

I have a website with galleries ported in from Facebook albums that just stopped working a few day sago. After hours and hours of research I have found that Facebook recently changed their policy and no longer allows 3rd party access to Facebook data, public or otherwise, without an access_token. Yes, you can grab one from the Graph Explorer, but it'll expire quickly.

I don't know how to build apps so I'm planning on just ditching the Facebook interface and hosting all my galleries on my own server. This was my javascript that used to work and just stopped working:

$.getJSON('https://graph.facebook.com/ALBUM_ID/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('#gallery-container');
});
});