ShareKit icon indicating copy to clipboard operation
ShareKit copied to clipboard

is there a method to share a link with a preview in facebook?

Open isaac1972 opened this issue 14 years ago • 8 comments

Hi, is there a way to share an url, with a preview (image + text caption + title) with sharekit? I'm currently using sharekit in my app and I can share a link(url) with a title, or an image (that is in the resource folder) along with the title, but I would like to share a preview (as it happens when you share a web-link to facebook from an internet browser)... And I can't find the way to do it...

isaac1972 avatar May 23 '11 14:05 isaac1972

You can modify the send method of SHKFacebook.

For Ex:

if (item.shareType == SHKShareTypeURL)
{
    self.pendingFacebookAction = SHKFacebookPendingStatus;

    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
    dialog.delegate = self;
    dialog.userMessagePrompt = s_entermessage;
    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.caption == nil ? @"" : item.caption,
                         item.link == nil ? @"" : item.link,
                         item.link == nil ? @"" : item.link
                         ];

    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
                          SHKEncode(SHKMyAppName),
                          SHKEncode(SHKMyAppURL)];
    [dialog show];

}

murderer1234 avatar Jun 05 '11 03:06 murderer1234

awesome man! thank you. you saved me a lot of time

ghost avatar Jun 08 '11 09:06 ghost

thanks murderer1234, I tried your code but I have some issues, nagiobeid, did it work for you?

isaac1972 avatar Jun 08 '11 09:06 isaac1972

this is my version (modified a little) and it works at it should.

if (item.shareType == SHKShareTypeURL)
{
    self.pendingFacebookAction = SHKFacebookPendingStatus;

    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
    dialog.delegate = self;
    dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:");
    dialog.attachment = [NSString stringWithFormat:
                         @"{\
                         \"name\":\"%@\",\
                         \"href\":\"%@\",\
                         \"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]\
                         }",
                         item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                         SHKEncodeURL(item.URL),
                         SHKEncodeURL(item.URL),
                         SHKEncodeURL(item.URL) 

                         ];
    dialog.defaultStatus = item.text;
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
                          SHKEncode(SHKMyAppName),
                          SHKEncode(SHKMyAppURL)];
    [dialog show];

}

ghost avatar Jun 08 '11 10:06 ghost

yes, no issues. But I still can't get anything else than the url with a title grabbed from the webpage I'm currently viewing.. With this code: what am I doing wrong?

 NSString *title = [webView pageTitle];
 SHKItem *item = [SHKItem URL:webView.request.URL title:title];
 SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
 [actionSheet  showFromToolbar: (UIToolbar *)bar];

isaac1972 avatar Jun 08 '11 18:06 isaac1972

there is nothing wrong with your code. the code i provided gives you a preview of a link containing an image (it can be modified to either flash or music). if you are trying to share a preview of a webpage, i don't think it is possible. see http://developers.facebook.com/docs/guides/attachments/ but i am not sure. if you find a way to do it, I'd be glad to see how it works.

ghost avatar Jun 09 '11 06:06 ghost

I'll try... By the way thank you very much for your help to both of you.

isaac1972 avatar Jun 09 '11 08:06 isaac1972

sir please help me.. after including this i am getting 10 errors. the errors are..

Property 'pendingFacebookAction' not found on object of type 'SHKFacebook *' please sir help me .. urgent

Abhicse079 avatar Mar 21 '12 08:03 Abhicse079