开发者

How to post on friend wall using Graph Api in iPhone

i am implementing a facebook application , i have used Graph Api and have successfully logged into facebook and got the friend list with the id in UITableView, now i have one string, how should i post on friend wall, Suppose if i click on any of my friend in UITableView, a message should be post,plz help me

EDIT: Code

NSString *urlString = [NSString stringWithFormat:@开发者_如何学Python"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]; 

i am implementing this in function when clicked on tableview where key is id number for the friends name clicked in and in other function

NSString *responseString = [request responseString];
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *postId = [responseJSON objectForKey:@"id"];
NSLog(@"Post id is: %@", postId); 

but i am getting the post id nil plz help me


Are you using the Facebook iOS SDK?

Assuming you are, use requestWithGraphPath e.g.-

[_facebook requestWithGraphPath:@"uid/feed"
                                andParams:[NSMutableDictionary dictionaryWithObject:@"Post on wall" forKey:@"message"]
                                andHTTPMethod:@"POST"
                                andDelegate:self];

Where uid is the user id of the user, naturally.

You'll need to make sure you have the relevant permissions when signing in to Facebook and handle the delegate call back to test for success.

If you're not using the SDK, you can do a similar thing with the Graph API directly, perhaps using your own NSURLConnection's or a third party library like ASIHTTPRequest. The SDK is pretty good and straightforward to use mind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜