2012-01-23 52 views
0
  1. 我需要在下一个领域获取用户的好友资料:身份证,姓名,性别 ,生日,城市,国家,profileUrl,PIC,pic_small, pic_big,is_app_user。获取好友资料与图形API

    在我使用FB.Data.query之前,现在已经废弃了。

    FB.Data.query('select uid, first_name, last_name, name, pic, 
        pic_small, pic_big, birthday_date, sex, current_location, 
    profile_url, is_app_user from user where uid in (select uid2 from 
    friend where uid1 = {0}', uid). 
    
  2. 如何取得正在使用应用程序的朋友?

我可以得到所有字段,我需要,但例如,我需要做图片我需要额外的请求。我可以在单个请求中获得所有必需的字段吗?

回答

3

,您仍然可以使用相同的FQL查询与Graph APIJavaScript SDK

var query = 'SELECT uid, first_name, last_name, name, pic, pic_small, pic_big, birthday_date, sex, current_location, profile_url, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ' + uid; 
FB.api('/fql',{q:query}, function(response){ 
    console.log(response.data); 
}); 

您肯定也可以Graph API不使用FQL都得到几乎相同的数据:

FB.api('/'+uid+'/friends', { 
    fields: 'id,first_name,last_name,name,birthday,gender,location,link,installed' 
}, function(response){ 
    console.log(response.data); 
}); 

你有几分不同的名称和其他格式(例如location)以获取这些详细信息并在结果中错过图片详细信息,但这很简单,user图片是availa ble形式的URL http://graph.facebook.com/USER_ID/picture

use?type = square |小|正常|大来请求一张不同的照片

+0

都能跟得上。只有'FB.Data。*'方法已被弃用,请参阅http://developers.facebook.com/blog/post/561/ –

+0

上的详细信息非常感谢。但第二个变体不适合我,因为太多的请求。 [FQL](http://developers.facebook.com/docs/reference/fql/“FQL”) - 我需要什么 –

0

我也一直在使用PHP来解决这个问题。这是我想出了:

$user_friends = $facebook->api('/me/friends?fields=installed'); 
$user_players = array(); 
foreach ($user_friends['data'] as $userfriend) 
{ 
    if (array_key_exists('installed', $userfriend)) 
    { 
     array_push($user_players, $userfriend); 
    } 
}  
0
The Following Helps you to fetch user's friend details using graph api 

NSString friendId =10020020 //Store Friend ID; 

NSString * pRequestString = [NSString stringWithFormat:@"%@?fields=name,picture,work,hometown,birthday,devices,interests",friendId]; 


    [[FBRequest requestForGraphPath:pRequestString ] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 

     NSLog(@"%@",result); 

    }]; 
相关问题