我有一个网站并使用 facebook 登录。我想做以下事情:
用户访问我的网站 - 使用 facebook 登录 - 我阅读了他的 facebook 数据和摄影许可
例如:
{
"id": "1"
"name": "John English"
"first_name": "John",
"last_name": "English"
"link": "https://www.facebook.com/johnenglish"
"username": "johnenglish"
"gender": "male"
"locale": "en_US"
....
}
和
{
"id": "2"
"name": "John English2"
"first_name": "John",
"last_name": "English2"
"link": "https://www.facebook.com/johnenglish2"
"username": "johnenglish2"
"gender": "male"
"locale": "en_US"
....
}
两个用户都有一张私人照片。我可以使用 javascript 使用我的 Web 应用程序从用户 (id: 2) 加载私人照片吗?你能给我举个例子吗?
我试过这个:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
FB.api('/USER-ID(USER ID 2)/photos?access_token=' + accessToken, function(response) {
//A user access token is required to request this resource.
});
} else if (response.status === 'not_authorized') {
} else {
}
});
错误:请求此资源需要用户访问令牌。