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

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!

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

Related

Facebook API Post Message On Friends Wall

I want to ask how to implement text view in Facebook API. I want to post message on friends wall and also how to get friends list and personal details from Facebook.
You have to use the IOS Facebook API. They created a quite detailed Introduction page.
Have a look here:
https://developers.facebook.com/docs/mobile/ios/build/
This image shows the whole process from authorization till publishing something on the news feed. (Also copied from the Facebook Developer tutorial)
Describing the process to get the friend list:
Facebook Api to check in users in an iOS app
Due to many of errors and many of negative comment about Open Graph API in facebook ios 6.
facebook remove the " Post to friends wall via the API ". You can only use the fbconnect of ios 5.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"100004925467891", #"to",
#"http://pri.com/pit.png", #"picture",
#"http://pr.com", #"link",
#"Data", #"caption",
#"data",#"description",
#"Birthday Reminder",#"name",nil];
[[delegate facebook] dialog:#"feed" andParams:params andDelegate:self];
But if u Post to own wall Open Graph API is still working.

How to get the photos related to a friend using facebook graph api?

I have all the list of friends which I get using
[facebook requestWithGraphPath:#"me/friends" andDelegate:self];.
Using this I get all the ids of my friends. I get all my photos too by using
[facebook requestWithGraphPath:#"me/photos" andDelegate:self];.
But what I should I use as the argument in requestWithGraphPath: if I want the photos related to any one of my friends?
Simple trick to fetch your friends photo.
[facebook requestWithGraphPath:#"FriendID/albums" andDelegate:self];
e.g
[facebook requestWithGraphPath:#"123456789/albums" andDelegate:self];
which returns album id along with some information.

How to display Facebook Fan Wall in iPhone App?

I would like to display Facebook Fan Wall like the way in the image below. Can you please let me know how it can be done?
Thanks!
You can pull in the list of wall feeds from https://graph.facebook.com/cocacola/statuses?access_token=... (a preview can be seen with the graph api explorer here). Then you would just parse the returned JSON and put them into UITableView cells.
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/comment on news feed programmatically through Facebook iOS Sdk iphone

I have integrated Facebook IOS SDK to my application and able to post news feed to user's wall programmatically in facebook. Now there is other requirement like in facebook we have options under each news feed of like/comment. I searched a lot for this but was not able to find anything related to this.
I am able to read the news feed from the user's wall and I have it in JSON format. I don't know the further implementation path for the same.
How can we achieve this functionality through iOS sdk?
No worries. With Legacy Rest API of facebook, I figured out how to Comment particular news feed.
//How to Like particular News FEED.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Your Comment Text.", #"text",#"NEWs_FEED_ID", #"object_id",nil];
[_facebook requestWithMethodName:#"comments.add" andParams:params andHttpMethod:#"POST" andDelegate:self];
//How to Like particular News FEED.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"NEWs_FEED_ID", #"post_id",nil];
[_facebook requestWithMethodName:#"stream.addLike"

How to post both text, image and link at once on friends' walls via facebook API

How to let someone post on his/her friends' walls via facebook API, similar to instagr.am iPhone application lets you post on your own wall?
How to show a list of friends and allow selecting them?
How to post both text, image and link at once?
As it happens, Facebook has an iOS SDK available, and instructions on how to use that to post feed items (either with an interactive dialog, or with their Graph API).
i did this way. it works fine.. u can post for multiple frnds as well.
NSMutableDictionary* params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
<appId>, #"api_key",
#"Happy Birthday....", #"message",
#"http://www.youtube.com/watch?v=wFh-rX_Sfhs", #"link",
#"http://www.99desi.com/wp-content/uploads/2011/03/Happy-Birthday.jpg", #"picture",
#"Many More Happy returns Of the Day...", #"name",
#" Believing hear, what you deserve to hear..", #"description",nil];
[facebook requestWithGraphPath:#"<frnd-ID>/feed" andParams:params1 andHttpMethod:#"POST" andDelegate:self];
u can iterate the above step to post same to multi friends.
hope it helps you...