Posting to message Facebook from iPhone/iPad - iphone

I have a 2-part question about posting messages to Facebook.
1 - I want to pre-populate the message that the user is going to post i.e. where it says 'Say something about this...'. Is this possible? If so, how? At the moment I have the following setup to produce the post shown below:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Steak Expert", #"name",
#"The must-have iPhone/iPad app for carnivores!", #"caption",
#"Steak Expert helps you to cook every steak to perfection! With this app in your hand you'll never need to worry about over-cooking or under-cooking a steak again. Perfection every time! ", #"description",
#"https://m.facebook.com/apps/MY_APP_ID/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Cooking a steak using Steak Expert!", #"message", // I thought this would be the required field to populate the text
nil];
[facebook dialog:#"feed" andParams:params andDelegate:nil];
2 - The other part of my question is based around the view shown above. Is it possible to automatically post to the wall without the need for this view to appear? Seeing as the user must authorise the app to even connect with Facebook (plus any other specified actions) I can't see it being an issue. If so please could someone advise on how to achieve this?

It is the message field that you are talking about.
message - This field will be ignored on July 12, 2011 The message to prefill the text field that the user will type in. To be compliant with Facebook Platform Policies, your application may only set this field if the user manually generated the content earlier in the workflow. Most applications should not set this.
http://developers.facebook.com/docs/reference/dialogs/feed/
Hope this helps

As #Illep stated, the message field no longer works for the dialog postings.
To answer your second question, you can use the graph API to straight post to a user's wall without showing the dialog box. Take a look at the documentation here. You would use the following code to write the message:
// Set parameters
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:FACEBOOK_ACCESS_TOKEN forKey:#"access_token"];
[params setObject:#"Some preset message" forKey:#"message"];
// Make the request to the graph API
[_facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];

Related

Facebook permissions required to tag a friend in a wall post..?

I want to tag a friend in a post which I am posting on my wall , just wanted to know what permissions are required...?
I am using the following code...
For permissions..
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"friends_online_presence",
#"read_stream",
#"email",
#"publish_stream",
nil];
[self.appDelegate.facebook authorize:permissions];
[permissions release];
and to post
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test 2",#"message",
#"100004311843201,1039844409", #"to",
nil];
[self.appDelegate.facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
This gets posted on wall successfully but the profile ids are not included...
Though its in PHP here is bug report which says it is problem in Graph API while posting status update and tagging friends is not working properly.
It says that it will post status update but tagging is not working.
EDIT:
As discussed with OP in comments, adding place field attached to parameters it is working.
I think this should help you:
To mention a user in a user message, place this string inline with the message: #[userID] or #[profileUrl]. This creates an inline hyperlink to the profile of the mentioned friends and sends them a notification that they have been tagged.
Taken from: https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
For tag friends in Facebook friends id are required to tag in post etc.
customer friend picker is better for tag friends.
see below Facebook sample
https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpa1/t39.2178-6/851564_497226807066458_2037734970_n.png
for this purpose us this graph api taggable_friends to get tag able friends
for more detail visit this link and read tag section (Mention Tagging is suite for your requirements)
mentiontagging detail info

How to limit facebook apprequests to certain users?

I have a iOS mobile application that needs to send out an app request to a user's friends. From here:https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk and here:https://developers.facebook.com/docs/reference/dialogs/requests/#mfs it appears I am able to suggest the users that this app requesst gets sent to. I am making the call like this:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Check out this awesome app", #"message",
#"1xxx4,10xxxx0,", #"suggestions",
nil];
[self.facebook dialog:#"apprequests"
andParams:params
andDelegate:nil];
However, once the multi-friend request dialog is presented, I am still able to type in a friends name, even if it was not part of the "suggestions". How do I make this restriction?
The end goal is to restrict that list to facebook friends who are not users of this app. The docs also mention a "filters" parameter, but i have not got that to work.
Ideas?

Facebook Graph api wall post not as link

Using the graph api I can post to a users wall:
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"https://developers.facebook.com/ios", #"link",
#"http://www.xmaselves.co.uk/wp-content/uploads/2012/05/gym.png", #"picture",
[self getTitleText], #"name",
[self getCaptionText], #"caption",
[self getFbFormattedDescription], #"description",
_comment.text, #"message",
nil];
[FBRequestConnection
startWithGraphPath:#"me/feed"
parameters:postParams
HTTPMethod:#"POST" .... etc
The problem is this only seems to post on the wall as a link:
I want the post to appear as normal and not as a 'shared a link' post. How do achieve this with the graph api.
EDIT
Removing the link paramater and making sure #message is specified will indeed post to the wall.
If you remove the link paramater and do not specify message nothing is posted and no error is returned!
In the screenshot 'asdadasd' would be the user entered message but this is optional! So if they don't enter a message the post wont be displayed! As a matter of fact this same behaviour is exhibited by the 'Feed dialogue' api.
So all posts need to have a message? or posted as a link? This doesn't seem right.

Facebook Feed Dialog keeps asking for permission

I've been trying to post a link on user's wall, by using Facebook SDK for the iOS.
I'm trying the code below and it works perfectly when I don't have the Facebook App installed. But when I have it, it just ask me to authenticate and send me back to the App. It happens even just to say that I've already gave the necessary permission, but never shows the dialog to do the share.
The code is:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:#"%# %.0f%% OFF", self.offer.description,
[self.offer.price.discountPercent doubleValue] * 100], #"name",
self.offer.store, #"caption",
self.offer.imageKey, #"picture",
#"Test", #"description",
[NSString stringWithFormat:#"http://my_url.com/id%#", self.offer.offerId], #"link",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
Any idea? Thank you in advance ;)
I think this is becouse of you login/logout code. when you making an autorization request to FB, one of params you sending is how long access token must "live". Make shure it lives long anoth. Or, somewhere in the code you invalidating it. May be even losting pointer to access token or something. Make sure, that acces token you use to post is validate at the moment you posting. I suggest you to use official SDK for FB: it's really simple and without any problems. There is great tutorial how to use it: http://developers.facebook.com/docs/mobile/ios/build/

How to publish the content in facebook of iphone

I am new to iphone development.I have created facebook application and i have displayed the login page and publish page. now i want to share my content(title and summary) display dynamically.
i dont know how to give the contents dynamically,
Here my code and display statically, it will published.
but i want to give my contents dynamically displayed.
titles and summaries are stored in the mutable arrays.
NSString *art;(titles are stored)
NSString *summ; [Summary are stored];
fbAgent.shouldResumeSession =YES;
[fbAgent publishFeedWithName:#"Sample"
captionText:#"Test Application"
imageurl:#"http://amanpages.com/wordpress/wpcontent/uploads/2009/12/logo2.png"
linkurl:#"http://www.yahoo.com"
userMessagePrompt:#"Share Something about this article"
actionLabel:nil
actionText:#"Search Google"
actionLink:#"http://wwww.google.com"];
This sample code and downloaded in the net. now i want to shared to publish title and summary.
Plz help me out,
Using the fbagent, you cannot publish title+description only, you have to also provide a link to an image and a webpage url.
The image can be your iPhone app icon stored on your site and webpage url can be appstore download link of your iPhone app.
This will help popularize and advertise your app.
So, minimum you can do is:
fbAgent.shouldResumeSession = YES;
[fbAgent publishFeedWithName:art
captionText:summ
imageurl:#"http://amanpages.com/wordpress/wp-content/uploads/2009/12/logo2.png"
linkurl:#"http://amanpages.com/"
userMessagePrompt:#"What do i think:"];
Hope it helps.
just check this example:
NSMutableDictionary* params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
appId, #"api_key",
#"Happy Holi", #"message",
#"http://www.holifestival.org/holi-festival.html", #"link",
#"http://www.onthegotours.com/blog/wp-content/uploads/2010/08/Holi-Festival.png", #"picture",
#"Wanna Kno abt HOLI.. Check this...", #"name",
#"Wish u 'n' Ur Family, a Colourful day...", #"description",
nil];
[facebook requestWithGraphPath:#"me/feed" andParams:params1 andHttpMethod:#"POST" andDelegate:self];
It will publish to your wall. If you want to publish to friends wall,then replace 'me' with [friend facebook UID].
[facebook requestWithGraphPath:#"1908979/feed" andParams:params1 andHttpMethod:#"POST" andDelegate:self];