如何在iPhone中使用Graph Api在朋友墙上发帖
我正在实现一个facebook应用程序,我使用了Graph Api并成功登录facebook,在UITableView中获得了id为的好友列表,现在我有一个字符串,我应该如何在好友墙上发布,假设如果我在UITableView中单击我的任何好友,应该发布一条消息,请帮助我 编辑:代码如何在iPhone中使用Graph Api在朋友墙上发帖,iphone,facebook,Iphone,Facebook,我正在实现一个facebook应用程序,我使用了Graph Api并成功登录facebook,在UITableView中获得了id为的好友列表,现在我有一个字符串,我应该如何在好友墙上发布,假设如果我在UITableView中单击我的任何好友,应该发布一条消息,请帮助我 编辑:代码 NSString *urlString = [NSString stringWithFormat:@"graph.facebook.com/%@/feed",key]; NSURL *url = [NSURL URL
NSString *urlString = [NSString stringWithFormat:@"graph.facebook.com/%@/feed",key];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url];
[newRequest setPostValue:@"I'm inviting you to see download the OGC app" forKey:@"message"];
[newRequest setPostValue:fbGraph forKey:@"access_token"];
[newRequest setDidFinishSelector:@selector(postToWallFinished:)];
[newRequest setDelegate:self];
[newRequest startAsynchronous];
我在点击tableview时实现了这个函数,其中键是在其他函数中点击的朋友姓名的id号
NSString *responseString = [request responseString];
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *postId = [responseJSON objectForKey:@"id"];
NSLog(@"Post id is: %@", postId);
但是我得到的是post-id-nil请帮助我你正在使用
假设您是,请使用requestWithGraphPath
-
[_facebook requestWithGraphPath:@"uid/feed"
andParams:[NSMutableDictionary dictionaryWithObject:@"Post on wall" forKey:@"message"]
andHTTPMethod:@"POST"
andDelegate:self];
其中,uid
自然是用户的用户id
您需要确保在登录Facebook时拥有相关权限,并处理代表的回拨以测试是否成功
如果您不使用SDK,可以直接使用Graph API执行类似的操作,可以使用您自己的NSURLConnection或第三方库,如ASIHTTPRequest。SDK非常好,使用起来非常简单。您使用的是
假设您是,请使用requestWithGraphPath
-
[_facebook requestWithGraphPath:@"uid/feed"
andParams:[NSMutableDictionary dictionaryWithObject:@"Post on wall" forKey:@"message"]
andHTTPMethod:@"POST"
andDelegate:self];
其中,uid
自然是用户的用户id
您需要确保在登录Facebook时拥有相关权限,并处理代表的回拨以测试是否成功
如果您不使用SDK,可以直接使用Graph API执行类似的操作,可以使用您自己的NSURLConnection或第三方库,如ASIHTTPRequest。SDK非常好,使用起来也非常简单。在uitableview中,我尝试调用函数作为后期提要,但没有帮助请求的原始响应字符串的输出是什么?在uitableview中,我尝试调用函数作为后期提要,但没有帮助请求的原始响应字符串的输出是什么?NSString*urlString=[NSString stringWithFormat:@;NSURL*url=[NSURL URLWithString:urlString];ASIFormDataRequest*newRequest=[ASIFormDataRequest requestWithURL:url];[newRequest setPostValue:@“我邀请您查看下载OGC应用程序”forKey:“消息”];[newRequest setPostValue:fbGraph forKey:@“访问令牌”];[newRequest setDidFinishSelector:@selector(postToWallFinished:)];[newRequest setDelegate:self];[newRequest startAsynchronous];我在函数中实现了这一点,当单击TableView时,其中键是在其他函数中单击的朋友姓名的id号NSString*responseString=[request responseString];NSMutableDictionary*responseJSON=[responseString JSONValue];NSString*postId=[responseJSON objectForKey:@“id”];NSLog(@“Post id为:%@”,postId);但我得到的是Post id为零。请帮助我,我认为您的意思是代码与您的问题相匹配。我将其移到那里。NSString*urlString=[NSString stringWithFormat:@”;NSURL*url=[NSURL URLWithString:urlString];ASIFormDataRequest*newRequest=[AsiformDataRequestWithURL:url];[newRequest setPostValue:@“我邀请您查看下载OGC应用程序”forKey:@“message”];[newRequest setPostValue:fbGraph forKey:@“access_token”];[newRequest setDidFinishSelector:@selector(postToWallFinished:)];[newRequest setDelegate:self];[newRequest startAsynchronous];当单击TableView时,我在函数中实现了这一点,其中键是所单击的朋友姓名的id号,在其他函数中NSString*responseString=[request responseString];NSMutableDictionary*responseJSON=[responseString JSONValue];NSString*postId=[responseJSON objectForKey:@“id”];NSLog(@“Post id为:%@”,postId);但我得到的帖子id为零。请帮助我,我认为你的意思是,代码与你的问题一致。我将把它移到那里。