如果用户喜欢某个页面,我遇到了返回问题。
如果我使用我的admin userID
尝试FB.api("/me/likes/259239627467123",.. return correct: [Object { category="Travel/leisure", name="KatkaFodor Bt.", created_time="2014-07-10T13:33:54+0000", ...}]
但是如果我有另一个用户ID FB.api("/me/likes/259239627467123",.. return empty data: Array[0]
我的问题在哪里?
var token='';
window.fbAsyncInit = function() {
FB.init({
appId : '1506526099561855', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
scope: 'user_likes',
});
FB.getLoginStatus(function(response){
console.log("Token:"+response.authResponse.accessToken);
console.log("User ID:"+response.authResponse.userID);
token=response.authResponse.accessToken;
FB.api(
"/me/likes/259239627467123",
function (response) {
if (response && !response.error) {
console.log(response);
/* handle the result */
console.log("User likey!");
//document.getElementById('nolikey').style.display = "none";
} else {
console.log("User no likey :("+response.error.message);
}
}
,{access_token: token});
});
};
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function Login()
{
FB.login(function(response) {
if (response.authResponse)
{
getUserInfo();
}
else
{
console.log('User cancelled login or did not fully authorize.');
}
},{scope: 'email,user_likes'});
}
function getUserInfo()
{
FB.api('/me', function(response) {
console.log(response);
var str="<b>Name</b> : "+response.name+"<br>";
str +="<b>Link: </b>"+response.link+"<br>";
str +="<b>id: </b>"+response.id+"<br>";
str +="<b>Email:</b> "+response.email+"<br>";
document.getElementById("status").innerHTML=str;
});
}
答案 0 :(得分:0)
&#34; user_likes&#34;权限必须得到Facebook团队的批准才能供非应用管理员用户使用。
有关详细信息,请参阅更改日志:https://developers.facebook.com/docs/apps/changelog