简体   繁体   中英

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:@"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 eg-

[_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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM