How to Share an Image to facebook?

二次信任 提交于 2019-12-06 13:53:44

问题


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

I am greatly appreciative of any guide or help.


回答1:


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.




回答2:


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



回答3:


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/



来源:https://stackoverflow.com/questions/6093841/how-to-share-an-image-to-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!