json - 公共(public)相册突然需要access_token

标签 json facebook api

我一直在使用以下代码将相册移植到网站,但它突然停止工作。相册和照片是公开的,但似乎需要 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/

相关文章:

javascript - 无法在 JavaScript 中访问 JSON 数组的值

json - 如何使用终端下载部分 s3 aws cli?它是一个 1 TB 的 json/xml 文件,我只想要 100-200MB 的顺序编号文件

java - Facebook 与 Android 上的 libgdx 集成

php - 用于更新通过 facebook 连接导入的用户配置文件数据的 cron 作业

api - 什么是用于登录Amazon Cognito用户池的REST(或CLI)API

javascript - 如何向外部 API 发出 GET 和 POST 请求?

api - 查看和设置 Safari/Chrome 的 HTTP header

c - 如何在 Jansson 中指定要输出实数的位数

python - 用于 Python 集群计算的快速 JSON 序列化(以及与 Pickle 的比较)?

javascript - Cordova:使用 javascript api 登录 facebook 不工作