Publishing links to user's wall using Facebook iOS SDK - iphone

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

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.

Creating a Facebook event on public FB Page using iPhone SDK Graph API

I'm trying to let users create an event on my public Facebook page via an iPhone app, and hopefully let ppl invite their friends to that event.
The idea is that the iPhone app will be able to show the users events from that page, while everyone is able to add the events.
After Authorizing with permissions: create_event and manage_pages, i'm trying to run the following code:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Event",#"name",
PAGE_ID, #"page_id",
#"2011-11-10T13:30",#"start_time",
#"2011-11-11T13:30",#"end_time", nil];
[facebook requestWithGraphPath:[NSString stringWithFormat: #"%#/events", PAGE_ID]
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
And I get and error saying: "(#200) Permissions error".
Is it even possible? (creating an event on a page which a user doesn't own)
and if so, what am I missing?
permissions = [[NSArray alloc] initWithObjects:#"offline_access", #"user_events",#"create_event",#"rsvp_event", nil];
I hope that it is just your help.

postToWall on facebook After login in iphone

Does anybody have idea about how to post a wall on
facebook after login button in iphone.
i have to post default image and text.
If yes in which fb class it have to write .i have latest sdk for facebook.
Thanks
using FBConnect library after login you can use the following method to post on the users wall
Facebook *facebook = [[[UIApplication sharedApplication] delegate] facebook];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"###yourAPIKeY###", #"api_key",
#"###Your Message###", #"message",
#"###link if you want###", #"link",
#"### a picture if you want###", #"picture",
#"###name of your fb app###", #"name",
#"###Description###", #"description",
nil];
[facebook requestWithGraphPath:#"me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
If you want it to happen right after the user logged in it should be implemented in the following method:
-(void) fbDidLogin
{
}
be sure to note that you need to ask from the user publish_stream permissions

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?

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