我有一個應用程序與Facebook登錄和登錄和獲取基本的個人資料信息工作正常。但是,當我嘗試獲取Facebook朋友(只返回也使用相同應用的朋友)時,我從Facebook API獲取[object Object]
。我有權設置好朋友(根據我的應用的Facebook開發者頁面)。Facebook圖形API我/朋友沒有返回
我的代碼看起來像這樣(我使用PhoneGap的插件,但該代碼是類似於JS版Facebook的API):
// Login function (permissions included)
var login = function() {
if (!window.cordova) {
var appId = prompt("123456789101112", "");
}
facebookConnectPlugin.login(["email, user_friends"],
// SUCCESS
function (response) {
alert('Login successful!');
},
// FAILURE
function (response) {
alert('Login failed')
}
);
}
// Get the friends
var getFacebookFriends = function() {
facebookConnectPlugin.api("me/friends",
// FAILURE
function(response) {
alert('Retrieving Facebook friends failed');
},
// SUCCESS
function(response) {
alert(JSON.stringify('Facebook friends: ' + response));
});
}
警報說Facebook friends: [object Object]
。我確信我有一位朋友也使用相同的權限登錄到應用程序。他沒有出現在名單上,只有空的[object Object]
。爲什麼我會得到這個迴應,而不是朋友的名單?
不知道你爲什麼提到var關鍵字(在這種情況下它並不重要),但我不會爲這個簡單的任務使用jquery ... – luschn