Ahmad Kayyali
Ahmad Kayyali

Reputation: 8243

How to Share an Image to facebook?

How to share an image from an iPhone application to facebook?

I am greatly appreciative of any guide or help.

Upvotes: 1

Views: 24987

Answers (3)

vinzenzweber
vinzenzweber

Reputation: 3389

You always HAVE to open the Facebook app first (or a WebView in case the App is not installed) to get a login token. Try using BMSocialShare which is a simple lib I wrote. It helps you sharing images and normal posts to Facebook, Twitter or Email. It let's you upload some local image (and even open a dialog for the user to add a comment) to the user's wall:

BMFacebookPost *post = [[BMFacebookPost alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
[[BMSocialShare sharedInstance] facebookPublish:post];

or do something more enhanced:

BMFacebookPost *post = [[BMFacebookPost alloc] 
                        initWithTitle:@"Simple sharing via Facebook, Email and Twitter for iOS!" 
                        descriptionText:@"Posting to Facebook, Twitter and Email made dead simple on iOS. Simply include BMSocialShare as a framework and you are ready to go." 
                        andHref:@"https://github.com/blockhaus/BMSocialShare"];    

[post setImageUrl:@"http://www.blockhausmedien.at/images/logo-new.gif" 
         withHref:@"http://www.blockhaus-media.com"];

[post addPropertyWithTitle:@"Download" 
           descriptionText:@"github.com/blockhaus/BMSocialShare" 
                   andHref:@"http://github.com/blockhaus/BMSocialShare"];

[post addPropertyWithTitle:@"Developed by" 
           descriptionText:@"blockhaus" 
                   andHref:@"http://www.blockhaus-media.com"];

[[BMSocialShare sharedInstance] facebookPublish:post];

Upvotes: 1

chings228
chings228

Reputation: 1889

first , you need to get permission for publish_stream , otherwise photo share won't show at wall or in album automatically

for detail , you can refer to

http://chings228.wordpress.com/2012/04/06/facebook-ios-login-part-3/

Upvotes: 0

Praveen S
Praveen S

Reputation: 10393

There is a Ray Wenderlech tutorial on how to use the new Facebook graph API.

http://www.raywenderlich.com/1488/how-to-use-facebooks-new-graph-api-from-your-iphone-app

Now once you have got the user giving you persmission, in your case it would be publish_stream. You can call the graph API with the parameters to post a photo on the wall.

You will need to dig into the developers help guide to find accurately the Graph api which meets your requirement. You will have to then use the accesstoken got from the first step to make the subsequent calls.

Upvotes: 1

Related Questions