【发布时间】:2013-12-05 21:32:30
【问题描述】:
我正在尝试在 ios 中使用 SLRequest 获取 Facebook 帐户详细信息。
我获得了所有详细信息但无法获得用户的个人资料照片链接。
我的代码如下:
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
@"xxxxxxxxxxxxxx", ACFacebookAppIdKey,
[NSArray arrayWithObjects:@"email", nil] , ACFacebookPermissionsKey,
nil];
[_accountStore requestAccessToAccountsWithType:facebookTypeAccount
options:options
completion:^(BOOL granted, NSError *error) {
if(granted){
NSArray *accounts = [_accountStore accountsWithAccountType:facebookTypeAccount];
_facebookAccount = [accounts lastObject];
NSLog(@"Success");
[self me];
}else{
// ouch
NSLog(@"Fail");
NSLog(@"Error: %@", error);
}
}];
- (void)me{
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", meDataString);
NSJSONSerialization *js=[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:nil];
NSLog(@"%@",js);
}];
}
帮我解决这个问题。
【问题讨论】:
标签: ios iphone facebook facebook-graph-api slrequest