(这与这个问题非常相似,但给出的答案并不相关
add image and description on facebook with sharekit )
如何使用ShareKit向图像发送链接,以便在共享时显示如下:
或者,或者,我可以将FB应用程序设置为在发布内容时始终显示大图标吗?
答案 0 :(得分:3)
(回答我的问题)
我更改了文件SHKfacebook.m,将dialog.attachment行更改为:
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\"
:\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"http://example.com/example.png\"
,\"href\": \"http://example.com/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL)
SHKEncode(item.title),SHKEncodeURL(item.URL)];
(粘贴后将其设为一行)
你可以看到有一个图片网址 - http://example.com/example.png - 大概应该是76 X 90px,还有一个链接网址 - http://example.com/
您可能还需要明确设置sharetype。我已经注意到3G / 3GS iPhone,除非你这样做,否则它不起作用:
item.shareType = SHKShareTypeURL;
[SHKFacebook shareItem:item];
答案 1 :(得分:1)
SHKFacebook * sharer = [ [ [ SHKFacebook alloc ] init] autorelease ];
SHKItem * item = [ SHKItem URL:[ NSURL URLWithString:@"http://google.com" ]
title:@"my title"
contentType:SHKURLContentTypeUndefined ];
item.facebookURLShareDescription = @"my description";
item.facebookURLSharePictureURI = @"http://www.userlogos.org/files/logos/pek/stackoverflow.png";
[ sharer loadItem:item ];
[ sharer share ];
答案 2 :(得分:0)
这是我对答案的修正案,它可以在分享到Facebook时分享标题,图片和说明。享受它
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\":\"%@\",\"description\":\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"http://4.bp.blogspot.com/-77BXdZj0M6o/Tr0t9pndpOI/AAAAAAAAAQ4/j3KWIE9ov1E/s1600/Blue_Eye_by_SapphiraBlue.jpg\" ,\"href\": \"%@/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),SHKEncodeURL(item.URL), @"Testing Description Comes Here", SHKEncode(SHKMyAppURL)];
答案 3 :(得分:0)
或者另一个解决方案是将图像和描述编辑为参数
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\":\"%@\",\"description\":\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"%@\" ,\"href\": \"%@/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),SHKEncodeURL(item.URL), item.text, item.filename, SHKEncode(SHKMyAppURL)];
dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:");
dialog.defaultStatus = @"";
通过简单地传递参数:
SHKItem *itemfb = [SHKItem image:@"" title:@"TITLE" url:url2];
itemfb.shareType = SHKShareTypeURL;
itemfb.text = @"DESCRIPTION COME HERE";
itemfb.filename = @"IMAGE PATH";
[SHKFacebook shareItem:itemfb];