iphone开发人员使用fbconnect api获取用户配置文件名、电子邮件
我用这个从我的iphone应用程序在facebook上贴墙iphone开发人员使用fbconnect api获取用户配置文件名、电子邮件,iphone,objective-c,Iphone,Objective C,我用这个从我的iphone应用程序在facebook上贴墙 kAppId =@"zsdgdfgjhjk"; if (!kAppId) { NSLog(@"missing app id!"); exit(1); return nil; } if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { _permission
kAppId =@"zsdgdfgjhjk";
if (!kAppId) {
NSLog(@"missing app id!");
exit(1);
return nil;
}
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
_permissions = [[NSArray arrayWithObjects:
// @"read_stream", @"publish_stream", @"offline_access",@"user_events",@"friends_events",@"rsvp_event",nil] retain];
@"read_stream",@"email", @"publish_stream", @"offline_access",@"user_events",@"friends_events",@"rsvp_event",@"create_event",nil] retain];
_facebook = [[Facebook alloc] initWithAppId:kAppId
andDelegate:self];
- (IBAction)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"a long run", @"name",
@"The Facebook Running app", @"caption",
@"it is fun", @"description",
@"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Share on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
nil];
[_facebook dialog:@"publish.stream"
andParams:params
andDelegate:self];
}
墙张贴是好的,但现在我想得到用户的facebook个人资料名称加上电子邮件,我正在尝试用户登录后的代码
[_facebook requestWithGraphPath:@"me?fields=id,name,email" andDelegate:self];
及
但即使此fbrequest委托方法-(void)request:(fbrequest*)request didLoad:(id)result
,它也不起作用,请不要调用它。导游,我已经在这里呆了很长时间了。提前谢谢。你好,萨阿德。试着这样做:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
}else{
NSLog(@"response is %@", result);
NSString *email =[result objectForKey:@"email"];
NSString *userFbId =[result objectForKey:@"id"];
// grab other fields
}
}
您将通过以下方式解析响应:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
}else{
NSLog(@"response is %@", result);
NSString *email =[result objectForKey:@"email"];
NSString *userFbId =[result objectForKey:@"id"];
// grab other fields
}
}
试着这样做:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
}else{
NSLog(@"response is %@", result);
NSString *email =[result objectForKey:@"email"];
NSString *userFbId =[result objectForKey:@"id"];
// grab other fields
}
}
您将通过以下方式解析响应:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
}else{
NSLog(@"response is %@", result);
NSString *email =[result objectForKey:@"email"];
NSString *userFbId =[result objectForKey:@"id"];
// grab other fields
}
}