ShareKit - posting linked image to facebook wall

岁酱吖の 提交于 2019-11-30 13:34:45

问题


( this is really the same as this question, but the answer given was not relevant

add image and description on facebook with sharekit )

How do I send a link to an image with ShareKit, so that when shared, it appears like so:

Or, alternatively, can I set the FB app to always show the big icon when something is posted?


回答1:


(answering my question)

I changed the file SHKfacebook.m changing the dialog.attachment line to read:

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

(make it one line after you paste in)

You can see there is an image url - http://example.com/example.png - which should be about 76 X 90px, and a link url - http://example.com/

You may also need to explicitly set the sharetype. I've noticed on 3G/3GS iPhones then it doesn't work unless you do this:

item.shareType = SHKShareTypeURL;
[SHKFacebook shareItem:item];



回答2:


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



回答3:


Here is my amendment for the answer and it can share the title, image and the description when share to facebook. Enjoy it

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



回答4:


Or another solution comes here for editing the image and description as parameters

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 = @"";

By passing the parameters simply like this:

SHKItem *itemfb = [SHKItem image:@"" title:@"TITLE" url:url2];
        itemfb.shareType = SHKShareTypeURL;
        itemfb.text = @"DESCRIPTION COME HERE"; 
        itemfb.filename = @"IMAGE PATH";
        [SHKFacebook shareItem:itemfb];


来源:https://stackoverflow.com/questions/7122414/sharekit-posting-linked-image-to-facebook-wall

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