Share content to Facebook from iOS 5 app

Marti Serra Vivancos picture Marti Serra Vivancos · Mar 10, 2012 · Viewed 16k times · Source

I'm developing a iOs 5 app and I would like that the user could share on Facebook some content from de app like text or images. I've tried to implement Sharekit (native fork and 2.0 modified fork) and Addthis but no one has worked. How can I do it? I was very close when I implement Sharekit 2.0 (modified fork) but it made some issues related to armv7. Is there some way for fixing them? Thanks for all!!

Answer

Jayson Lane picture Jayson Lane · Mar 10, 2012

I highly recommend using Facebook's SDK. There's a very thorough tutuorial here: Facebook iOS SDK. Once you've followed the instructions there and have Facebook authorizing your users account, you can use calls to the Graph API to post a variety of things (example of posting a link with the Graph API):

NSMutableDictionary *params = [NSMutableDictionary dictionary];

[params setObject:@"Test post" forKey:@"message"];
[params setObject:@"link" forKey:@"type"];
[params setObject:@"http://yoursite.com" forKey:@"link"];
[params setObject:@"Link description" forKey:@"description"];

NSString *graphPath = @"me/feed";

[facebook requestWithGraphPath:graphPath andParams:params andHttpMethod:@"POST" andDelegate:self];