如何在iPhone应用程序中使用FB图搜索API



我是facebook图形api的新手。我想从Facebook搜索人们,并在应用程序中显示用户Facebook的基本信息。如何使用 fb 图形搜索 API 搜索人员。任何人都可以告诉我教程或任何有用的链接。提前谢谢。

从 facebook 下载了最新的示例 Facebook Graph API for iOS 搜索,从 github 搜索图形 API,它包含相同的示例代码。

//调用 facebook graph API

NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook        requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError    *error) 
{
if(!error)
{
NSDictionary *list =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

用户的基本配置文件将保存在列表变量中

NSLog(@"Dictionary contains: %@", list );
fbID = [NSString stringWithFormat:@"%@", [list objectForKey:@"id"]];

获取脸书ID

gender = [NSString stringWithFormat:@"%@", [list objectForKey:@"gender"]];

获取性别 playerGender = [NSString stringWithFormat:@"%@", gender]; NSLog(@"Gender : %@", playerGender);

还导入社交帐户和安全框架

最新更新