is there a method to share a link with a preview in facebook?
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...
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];
}
awesome man! thank you. you saved me a lot of time
thanks murderer1234, I tried your code but I have some issues, nagiobeid, did it work for you?
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];
}
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];
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.
I'll try... By the way thank you very much for your help to both of you.
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