我正在尝试获取SLRequest
在 ios 中使用的 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);
}];
}
帮我解决这个问题。