ios 如何将图片分享到 Facebook?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6093841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Share an Image to facebook?
提问by Ahmad Kayyali
How to share an image from an iPhone application to facebook?
如何将图像从 iPhone 应用程序共享到 Facebook?
I am greatly appreciative of any guide or help.
我非常感谢任何指南或帮助。
采纳答案by Praveen S
There is a Ray Wenderlech tutorial on how to use the new Facebook graph API.
有一个关于如何使用新的 Facebook 图形 API 的 Ray Wenderlech 教程。
http://www.raywenderlich.com/1488/how-to-use-facebooks-new-graph-api-from-your-iphone-app
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.
现在,一旦您让用户授予您权限,在您的情况下它将是 publish_stream。您可以调用带有参数的图形 API 将照片发布到墙上。
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.
您需要深入研究开发人员帮助指南,以准确找到满足您要求的 Graph api。然后,您必须使用从第一步获得的访问令牌进行后续调用。
回答by vinzenzweber
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 BMSocialSharewhich 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:
您始终必须先打开 Facebook 应用程序(如果未安装该应用程序,则打开 WebView)以获取登录令牌。尝试使用BMSocialShare,这是我编写的一个简单的库。它可以帮助您将图像和普通帖子分享到 Facebook、Twitter 或电子邮件。它让你上传一些本地图像(甚至打开一个对话框让用户添加评论)到用户的墙上:
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];
回答by chings228
first , you need to get permission for publish_stream , otherwise photo share won't show at wall or in album automatically
首先,您需要获得 publish_stream 的权限,否则照片分享将不会自动显示在墙上或相册中
for detail , you can refer to
详细可以参考
http://chings228.wordpress.com/2012/04/06/facebook-ios-login-part-3/
http://chings228.wordpress.com/2012/04/06/facebook-ios-login-part-3/