iOS SDK 发布链接 &显示缩略图

发布于 2024-11-18 01:22:31 字数 1634 浏览 3 评论 0原文

在提供的 FB 文档的帮助下,我成功地将 Facebook iOS SDK 很好地实现到了我的项目中。

我的应用程序的 FB 集成非常简单:一个 Facebook 共享按钮,允许用户使用用户提供的评论发布到其 FB 墙的链接。没有什么惊天动地或开创性的事情。

然而,我想更进一步。我没有要显示的链接缩略图(即我自己的图像 URL),但我希望 Facebook 自动选择缩略图。

与在网络浏览器中的 Facebook 类似,如果您选择共享来自 CNN.com 的链接,Facebook 将自动选择要共享的所需页面的缩略图,甚至为您提供“无缩略图”复选框的选项。

从 iOS 对话框中共享链接,我希望自动选择缩略图(大概它是从您尝试共享的链接生成的,即 FB 只是从页面抓取图像)。

这可能吗?同样,我不想在下面的“附件”NSDictionary 中显示带有提供的图像 URL 的“图片”,因为我没有图像 URL。我只想显示一个超链接,并让 FB 将链接及其评论发布到用户的墙上,并让 FB 提供缩略图(类似于从网络浏览器发布的方式)。

基本上来自 Stack Overflow 的代码是:

SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary     
dictionaryWithObjectsAndKeys: @"Always Running", @"text", @"http://itsti.me/", @"href", 
nil], nil];

NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                           @"a long run", @"name",
                           @"The Facebook Running app", @"caption",
                           @"it is fun", @"description",
                           @"http://itsti.me/", @"href", nil];

NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                             @"Share on Facebook",  @"user_message_prompt",
                             actionLinksStr, @"action_links",
                             attachmentStr, @"attachment",
                             nil];

[_facebook dialog:@"stream.publish" andParams:params andDelegate:self];

I've managed to get the Facebook iOS SDK implemented into my project quite nicely with the assistance of the provided FB documentation.

My app's FB integration is quite simple: A Facebook share button, which allows a user to post a link to their FB wall with a user-supplied comment. Nothing earth-shattering or ground breaking.

However, I would like to go one step further. I don't have a thumbnail to display for the link (i.e. my own image URL), but I would like the thumbnail to be automatically selected by Facebook.

Similar to how, from Facebook in a web browser, if you choose to Share a link from CNN.com, Facebook will automatically select thumbnails for the desired page to be shared, AND it even gives you the option to checkbox "no thumbnail".

From the iOS dialog to share the link, I would like the thumbnail to automatically be selected (presumably it's generated from the link that you're trying to share, i.e. FB just grabs images from the page).

Is this possible? Again, I do not want to display "picture" with a supplied image URL in the 'attachment' NSDictionary below because I won't have the image URL. I just want to display a hyperlink and have FB post the link on the user's wall with their comment and have FB supply the thumbnail image (similar to how it would if you posted from a web browser).

Basically the code from Stack Overflow is:

SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary     
dictionaryWithObjectsAndKeys: @"Always Running", @"text", @"http://itsti.me/", @"href", 
nil], nil];

NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                           @"a long run", @"name",
                           @"The Facebook Running app", @"caption",
                           @"it is fun", @"description",
                           @"http://itsti.me/", @"href", nil];

NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                             @"Share on Facebook",  @"user_message_prompt",
                             actionLinksStr, @"action_links",
                             attachmentStr, @"attachment",
                             nil];

[_facebook dialog:@"stream.publish" andParams:params andDelegate:self];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初见 2024-11-25 01:22:31

另一种方法是调用 Graph API 而不是使用对话框。因此,如果您向 https://graph.facebook.com/me/feed 发送 HTTP POST并提供 Facebook 应自动选择图像的消息和链接参数。请参阅 https://developers.facebook.com/docs/reference/api/user /#链接

您必须生成 UI 来要求用户输入消息。如果这对你有用,那么这就是你要走的路。

A different approach to this would be to call the Graph API instead of using a dialog. So if you make an HTTP POST to https://graph.facebook.com/me/feed and supply the message and link parameters the image should be automatically selected by Facebook. See https://developers.facebook.com/docs/reference/api/user/#links.

You will have to generate the UI to ask the user to enter the message. If that can work for you then this is the way to go.

人间☆小暴躁 2024-11-25 01:22:31

我认为你不必发布照片。此外,Facebook 正在做的是获取开放图谱标签(网络文档开头的元标签就是为了这个目的)。您应该能够简单地发布链接和消息,它会“lint” - 读取元标记并发布该网页的图片、摘要等。

您可以尝试使用 Open Graph 图形操作而不是共享对话框。它会做更多你想要的事情。http://developers.facebook.com/docs/opengraph/

I don't think you have to post a picture. Also, what Facebook is doing is getting Open Graph tags (meta tags in the beginning of web documents just for this purpose). You should be able to simply post a link and a message, and it will "lint"- read the meta tags and post the picture, summary, etc. for that web page.

You may try using Open Graph graph actions instead of share dialogs. It will do more of what you want.http://developers.facebook.com/docs/opengraph/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文