【发布时间】:2014-07-16 13:16:43
【问题描述】:
我想使用 Facebook Api 来获取 Facebook 好友列表。因此,我在Facebook 上创建了新应用程序,并在我的原生 iOS 应用程序中使用该 AppID 和 Bundle ID 并使用 api 获取所有朋友列表时获取 AppID 并提供 Bundle ID。
如果我使用 "SendRequestHowTo" 示例项目的 App ID,它会获取登录用户的所有好友列表。告诉我如何在 Facebook 开发者网站上配置我的新应用程序以获取好友列表。
我的获取好友列表的代码:
// Query to fetch the active user's friends, limit to 25.
NSString *query =
@"SELECT uid, name, pic_square FROM user WHERE uid IN "
@"(SELECT uid2 FROM friend WHERE uid1 = me())";
// Set up the query parameter
NSDictionary *queryParam = @{ @"q": query };
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
_friends_list = (NSArray *) result[@"data"];
NSLog(@"Result: %@", result);
[self getLetsWalkeeFriendList];
// Sort Table Data
[self sortTableView];
// [_tbl_view_friends reloadData];
}
[self.view setUserInteractionEnabled:YES];
// [self.view hideToastActivity];
}];
使用示例项目 AppID(即 FacebookAppID:403223126407920 和 Bundle 标识符:com.facebook.samples.SendRequestsHowTo)。当我用 facebook 登录时,我得到了输出
Result: {
data = (
{
name = "Assad Sarwar";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/t1.0-1/c153.5.545.545/s50x50/1978738_766566543368250_230425531_n.jpg";
uid = 100000447351759;
},
{
name = "Muhammad Hassan Butt";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/t1.0-1/c0.0.50.50/p50x50/10167970_873047696055100_7845811348955741805_n.jpg";
uid = 100000496339789;
},
{
name = "Umair Jafar";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/t1.0-1/c0.2.50.50/p50x50/10500337_910092152350902_4827832642500691993_n.jpg";
uid = 100000503784242;
}, .........
)
}
当我使用 facebook 提供的 AppID 并使用同一用户登录 facebook 时,我得到了类似的输出
Result: {
data = ( )
}
【问题讨论】:
-
转到 developer.facebook.com
标签: ios facebook facebook-graph-api facebook-fql facebook-ios-sdk