Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Development: How can I get a Facebook wall post to show in the friend's news feed?

I'm integrating Facebook into my iPhone app and I have the code working to publish a post to the user's wall after they login, but I've noticed that the post doesn't show up in the user's news feed that's seen by the user's friends. Instead, it only shows up on the wall of the user. Here's my code...

- (void)publishStream 
{
 NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
           @"Post a message on your wall",  @"user_message_prompt",
           @"Hello, World!", @"message",
           nil];

 [facebook dialog:@"feed"
   andParams:params
    andDelegate:self];
}

How can I have it show up in the news feed as well? I should mention that the only permission I have set is 'publish_stream' which, as I understand it, is the only permission I need.

Thanks so much for your wisdom!

like image 897
BeachRunnerFred Avatar asked Jan 23 '11 23:01

BeachRunnerFred


1 Answers

You need to post to your friends feed, Easy way would be to adapt your code to use the appropriate graph method with the persons you wish to post to facebook ID (i've assumed here you have stored this from an earlier call the graph api in person.facebookID)

[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed/",person.facebookID] andParams:params andHttpMethod:@"POST" andDelegate:self

http://developers.facebook.com/docs/reference/api/post

To get a list of the users friends use the graph path me/friends

[facebook requestWithGraphPath:@"me/friends" andDelegate:self];

Which will return a JSON list of the users friends names and their Facebook ids, to the appropriate delegate method from FBRequest, its probably worth wrapping this set of results into a set of person objects or storing the returned NSDictionary so that you can retrieve individual friends, its upto you how you process the list of returned friends (you probably want to use a UITableView to display the user friends or filter based on some other input from the user)

Using this method will mean you do not have to use the Facebook dialogs in the iOS sdk, which does mean there is an upper limit to how many messages the user can post in a day using your app

If you wish to use a dialog you will need to include the "target_id" in your params dictionary and set this to the persons Facebook ID you wish to post to

like image 72
kgutteridge Avatar answered Oct 02 '22 12:10

kgutteridge