如何一次从几个ID获取照片和名称

时间:2011-09-02 21:47:03

标签: javascript facebook sdk

我想在应用中向访问者展示他们的朋友。我在应用程序中获得了朋友的身份,但我怎样才能立刻得到他们的名字和照片?有可能吗?

2 个答案:

答案 0 :(得分:0)

一旦用户批准了您的应用,您就可以使用此FQL查询:

SELECT uid, name, pic FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
AND is_app_user = 1

全功能:

function getFriends() {  
    FB.login(function(response) {
      if (response.session && response.perms) {
        FB.api(
          {
            method: 'fql.query',
            query: 'SELECT uid, name, pic FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'
          },
          function(response) {
            alert('Friends using app: ' + JSON.stringify(response));
          }
        );
      }
    } , {perms:''}); 
}

答案 1 :(得分:0)