[英]Get photos of Test User using Facebook API in javascript
I'm using Facebook API and I create a test user under Roles->TestUsers
with the premission of publish_actios, user_photos
When I login using this user and try to get photos or feeds it return empty response. 我正在使用Facebook API,并在
Roles->TestUsers
下创建了一个测试用户,其权限为publish_actios, user_photos
当我使用该用户登录并尝试获取照片或Feed时,它返回空响应。
Here is my javascript code. 这是我的JavaScript代码。
FB.api('me/feed', function(response) {
console.log(response);
});
This return response like this Object {data: Array[0]}
I try it with photos same result. 像这样的返回响应
Object {data: Array[0]}
我尝试了与照片相同的结果。 But when I try only FB.api('me',function...
it's working fine return name and id of this user but why this is not working for photos and feeds
. I upload some photos using this test user on facebook account. Sorry, I'm new in this and have not much knowledge about this. 但是,当我只尝试使用
FB.api('me',function...
时,该用户的返回名称和ID很好,但是为什么对photos and feeds
不起作用。我在Facebook帐户上使用该测试用户上传了一些照片。抱歉,我是新来的,对此知识不多。
UPDATE UPDATE
I debug the accessToken get these results. 我调试accessToken得到这些结果。
Application ID 1017793531681977 : codeDeveloper
User ID 104922836661684
Issued Unknown
Expires 1479805200 (in about an hour)
Valid True
Origin Unknown
Scopes user_photos, user_friends, email, publish_actions, public_profile
I also add three photos in test user account.I'm using this javascript code. 我还在测试用户帐户中添加了三张照片。我正在使用此javascript代码。
FB.api('me/photos',...
It return response Object {data: Array[0]}
why this is not getting any results. 它返回响应
Object {data: Array[0]}
为什么没有得到任何结果。 This is a test user and I didn't apply for any review permission. 这是测试用户,我没有申请任何审阅权限。 Because first I need any test user from where I can test my app and submit for reviews how can i do that.
因为首先我需要任何测试用户,我可以从那里测试我的应用程序并提交评论,我该怎么做。
UPDATE UPDATE
function statusChangeCallback(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
} else {
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '101**********77',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.8' // use graph api version 2.5
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function testAPI() {
FB.api('me/photos', function(response) {
console.log(response);
});
}
In HTML Body 在HTML正文中
<fb:login-button scope="public_profile,email,user_photos,publish_actions" onlogin="checkLoginState();">
publish_actions
is for posting, for reading the feed you need the user_posts
permission. publish_actions
用于发布,要读取供稿,您需要user_posts
权限。
user_photos
is correct for getting the photos, the endpoint is /me/photos
. user_photos
对于获取照片是正确的,端点是/me/photos
。
Debug the Token and make sure it includes the correct permissions: https://developers.facebook.com/tools/debug/accesstoken/ 调试令牌,并确保它包含正确的权限: https : //developers.facebook.com/tools/debug/accesstoken/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.