简体   繁体   English

如何使用FBConnect对话框方法将UIImage发布到我的墙上?

[英]How to use FBConnect dialog method to post a UIImage to my wall?

( Note: I've looked all over for this, and there are tons of examples for how to post a URL-to-image via dialog, and a few for how to post image-data direct to photo album, but neither of those are what I'm trying to do.) 注意:我已经到处寻找这些内容,并且有大量的示例如何通过对话框发布URL到图像,还有一些示例如何将图像数据直接发布到相册,但是这些都没有是我想要做的。)

I can post an image that's stored on the web easily enough with code similar to this: 我可以使用以下类似的代码轻松发布存储在网络上的图像:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
        @"This is what I say about kittens!", @"message",
        @"Kittens!", @"name",
        @"I'm feeling fuzzy", @"caption",
        @"You, too, can feel fuzzy, with FuzzyKitten™", @"description",
        @"http://example.com/fuzzykitten.html", @"link",
        @"http://placekitten.com/200/150", @"picture",
        nil];

[facebook dialog: @"feed"
            andParams: params
            andDelegate: self];

And everything works fine. 一切正常。 The problem is, I'd like to replace: 问题是,我想替换:

        @"http://placekitten.com/200/150", @"picture",

with something along the lines of: 与以下类似:

        [UIImage imageNamed: @"myImage.png"], @"picture",

which, of course, isn't right. 当然,这是不对的。 So my question is: If I have an image in UIImage form, how do I load that into the parameters dictionary to pass to the dialog method? 所以我的问题是:如果我有UIImage形式的图像,如何将其加载到参数字典中以传递给dialog方法?

Thanks! 谢谢!

EDIT: This is a client iPhone app for which there is no server so, while uploading the image to FB as part-1 of a 2-part process is fine, I'm now not seeing how to find the uploaded image's URL. 编辑:这是一个没有服务器的客户端iPhone应用程序,因此,将图像作为2部分过程的第1部分上传到FB很好,但是我现在看不到如何找到上传的图像的URL。 Thanks again! 再次感谢!

You can't directly upload an image to the wall, when publishing to the wall you can just link an image to it. 您无法将图像直接上传到墙上,而发布到墙上时,您只能将图像链接到墙上。
So, you need to upload the UIImage somewhere first. 因此,您需要先将UIImage上传到某个地方。 You have 2 options: 您有2个选择:
1. Upload to your/some server and publish a wall post linking to it. 1.上传到您的/某台服务器并发布链接到它的墙贴。
2. Upload to a facebook album. 2.上载到Facebook相册。 Check the graph API about doing that, it is pretty straightforward. 检查图形API的相关操作 ,这非常简单。

edit: you can no longer source images hosted in facebook CDN (and probably other CDNs), so if you need to link an image from a dialog you should upload it on a server and get a permalink from there 编辑:您无法再获取托管在Facebook CDN(可能还有其他CDN)中的图像,因此,如果需要从对话框链接图像,则应将其上传到服务器上并从那里获取永久链接

You could use ASIFormDataRequest and run a script to upload your file to your server using something like this: 您可以使用ASIFormDataRequest并运行一个脚本,使用以下方式将文件上传到服务器:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

// Upload a file on disk
[request setFile:@"/Users/ben/Desktop/ben.jpg" withFileName:@"myphoto.jpg" andContentType:@"image/jpeg"
forKey:@"photo"];

Then have the ASIFormDataRequest's response return the url of the uploaded image to your application. 然后,让ASIFormDataRequest的响应将上传的图像的URL返回到您的应用程序。 You can use the event of the ASIFormDataRequest response to trigger the Facebook image post. 您可以使用ASIFormDataRequest响应的事件来触发Facebook图像发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM