我一直在使用以下代码将相册移植到网站,但它突然停止工作。相册和照片是公开的,但似乎需要 access_token。
这是这张专辑的图表:
https://graph.facebook.com/483171821709416/photos
这是我一直在使用的 javascript:
$.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');
});
});
最佳答案
假设您拥有这些照片,并且它们确实是公开的,您所需要的只是生成一个页面访问 token ,该 token 不会过期。创建一个应用程序只需点击一个按钮,并设置一个域,不需要实际编码。然后你经历这个场景
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
关于json - 公共(public)相册突然需要access_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16345085/