How to publish the content in facebook of iphone - 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];

Related

FaceBook app request is shown on website only, but not on FB app

I'm sending an app request from my iphone app, using this code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Join my app", #"message", [NSString stringWithFormat:#"%#", [[filteredContacts objectAtIndex:path] valueForKey:#"id"]] ,#"to",
nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
while [[filteredContacts objectAtIndex:path] valueForKey:#"id"] returns a facebook ID value.
When a FB friend of mine gets the request he can see it in the notifications section on his facebook - but only on the website itself.
When trying to find it in the facebook iphone app - it's just not there. also, it's not found on the mobile site.
How can it be posible that I see the notification on the website only?
Well the answer was very simple -
I should have define the app as a mobile app when I created it as a FB app.

Posting to message Facebook from iPhone/iPad

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];

i want to share friend's post via graph api

I want to share some posts in facebook via graph api.
But there's no api like this. only "feed" exists.
I tried to use "me/feed" graph api action to share my friend's post(and post in page). but it's not same as i shared in facebook website. i want to know how.
source is..
NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];
NSString *linkURL = #"http://media.daum.net/society/others/view.html?cateid=1067&newsid=20120106140112792&p=munhwa&RIGHT_COMM=R4";
[fbArguments setObject:linkURL forKey:#"link"];
[facebook requestWithGraphPath:#"me/feed"
andParams:fbArguments
andHttpMethod:#"POST"
andDelegate:self];
[fbArguments release];
And I noticed there's no action for sharing friend's post(or photo), page's post via facebook iphone app. (so weird. don't you need this action?)
what can i do? can you help me?
Thanks.
i'v succeeded sharing photo. that is 'Link'.
source is
NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];
NSString *linkURL = #"https://www.facebook.com/photo.php?fbid=324225380935287&set=a.265279620163197.68309.194442110580282&type=1";
[fbArguments setObject:linkURL forKey:#"link"];
[fbArguments setObject:#"good!" forKey:#"message"];
[facebook requestWithGraphPath:#"me/feed"
andParams:fbArguments
andHttpMethod:#"POST"
andDelegate:self];
[fbArguments release];
i added message. and this is perfectly same as i shared via facebook web.
but there is one problem. this never makes back reference(trackback?).
if I share a photo via facebook web, I can see "5 shares" upper comment list, and my username is is there.
But this way, There is no my username. No trackback.
what can i do?
thanks.

iphone post to facebook wall

I am trying to get my iPhone application to post a message to a user's facebook wall.
I have created a facebook app and specified the value of the kAppId in my iphone application.
When i test the iphone app in the simulator, i am prompted to authorize the facebook application, which i accept. however, i then immediately get the message "safari cannot open the page because the address is invalid".
I am trying to troubleshoot this error but am not really getting anywhere. Could it be because my facebook app currently shows: "Directory Status: Not Submitted" ? (I am not able to submit it to the facebook App Directory until i have 5 - 10 users.)
FYI - I have added a "publish to facebook" button in one of my view controllers that responds with the following method:
-(IBAction) publishToFacebook {
facebook = [[Facebook alloc] initWithAppId:kAppId];
[facebook authorize:nil delegate:self];
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObjectsAndKeys: kAppId, #"app_id", #"http://www.something.com/", #"link", #"http://www.something.com/something.jpg", #"picture", #"My App Name", #"name", #"The Caption...", #"caption", #"The description...", #"description", #"the message...", #"message", nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
}
Thanks. Looks like i got this figured out. basically, just follow the instructions on developers.facebook.com/docs/guides/mobile/#ios) and be sure to prefix your app id with "fb" in the plist file (ex. fb123456789 where the facebook app id is 123456789)
Also, to answer my question, your facebook app does NOT need to be submitted to the directory for it to work with iPhone integration.
Did you update your info.plist file with your appid so it knows you to jump back to your app properly?

Publishing links to user's wall using Facebook iOS SDK

I'm trying to publish a link to the user's wall on Facebook after he has already logged in using the new Facebook iOS SDK.
I want the link to behave as if the user posted it from his account. For example, if I post this link on my Facebook wall: http://www.apple.com/, I won't see the link. What I'll see is an image, a caption with the actual url and a short description. But when I publish this same link from my app, all I see is the link itself.
How can I publish this url through my app so that what will eventually appear on the user's wall is the formatted message as it would appear if he would have posted it from his account on the pc, and not just the link itself as a string?
Thanks,
EDIT: The code below is for an OLD version of the FB SDK
Check here for a more up to date answer that may help Facebook sdk post on wall on iPhone app
OLD POST:
From http://developers.facebook.com/docs/reference/dialogs/feed/
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://developers.facebook.com/docs/reference/dialogs/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Facebook Dialogs", #"name",
#"Reference Documentation", #"caption",
#"Dialogs provide a simple, consistent interface for apps to interact with users.", #"description",
#"Facebook Dialogs are so easy!", #"message",
nil];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
You need to use FBStreamDialog for this. I do not have the exact code. Try this:
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = #"What's in your mind?";
dialog.attachment = #"{\"name\":\"Apple URL","
"\"href\":\"http://www.apple.com\","
"\"caption\":\"App Name\",\"description\":\"Posting link Test\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://www.apple.com\","
"\"href\":\"http://www.apple.com\"}],"
"\"properties\":{\"another link\":{\"text\":\"Apple home page\",\"href\":\"http://www.apple.com\"}}}";
[dialog show];