Facebook graph api 获取好友facebook mobile fb.ui hello world

Facebook graph api 获取好友facebook mobile fb.ui hello world,facebook-graph-api,mobile,fb.ui,Facebook Graph Api,Mobile,Fb.ui,我正在开发一个facebook移动网络应用程序。有以下功能 function getUserFriends() { FB.api('/me/friends&fields=name,picture', function(response) { console.log('Got friends: ', response); if (!response.error) { var markup = '';

我正在开发一个facebook移动网络应用程序。有以下功能

function getUserFriends() {
    FB.api('/me/friends&fields=name,picture', function(response) {
        console.log('Got friends: ', response);

        if (!response.error) {
            var markup = '';

            var friends = response.data;

            for (var i=0; i < friends.length && i < 25; i++) {
                var friend = friends[i];

                markup += '<img src="' + friend.picture + '"> ' + friend.name + '<br>' + friend.id + '<br>';
            }

            document.getElementById('user-friends').innerHTML = markup;
        }
    });
}
而它应该返回如下内容:

http://profile.ak.fbcdn.net/hprofile-ak-ash2/276211_285403872_5043326_q.jpg
我想我在我的facebook应用程序中配置了一些错误的东西,但不知道它是什么

[06:02:12.503]获取http//m、 mochirestaurant.com/fb/%5Bobject%20Object%5D[HTTP/1.1 404找不到77ms]

您可以看到,其中没有实际值,而是显示了
[object]
(括号为URL编码)–当您试图将对象放入字符串上下文时,浏览器会返回该值。(因为这不是以http://…开头的完整URL,所以浏览器将其视为相对地址,并尝试从您的域中请求它。)

显然,
friend.picture
此时在代码中不是一个字符串值,而是一个对象

(到目前为止,用于调试和发现错误部分。)

这源于关于用户/图片连接的问题

/picture connection将在指定回调时返回字典

当访问对象的/picture连接并指定回调属性时,我们将开始返回一个包含url、高度、宽度和is_轮廓字段的字典。目前,我们只是以字符串形式返回图片URL

因此,您必须在代码中使用
friend.picture.url
,以获取包含用户图片url的实际字符串属性

http://profile.ak.fbcdn.net/hprofile-ak-ash2/276211_285403872_5043326_q.jpg