如何在 Facebook for iPhone sdk 上添加好友 id 列表?
问问题
315 次
1 回答
4
//好友:https ://graph.facebook.com/me/friends?access_token=你的访问令牌
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@", token]]];
[request setHTTPMethod:@"GET"];
NSError *error;
NSURLResponse *response;
NSData *returnData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *returnString=[[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"%@",returnString);
SBJSON *json = [[SBJSON new] autorelease];
dic = [[NSMutableDictionary alloc] initWithDictionary:[json objectWithString:returnString error:nil]];
FriendIdArr=[[NSMutableArray alloc]initWithArray:[dic valueForKey:@"data"]];
// FriendIdArr 是最终好友 id 列表数组
于 2012-06-16T12:44:18.247 回答