I am using sharekit in my iPhone app to share url link on facebook. However, it seems to me that it is not possible to share url with image with sharekit. Do you guys know how to do it? Thanks a lot.
Please have a look to the code I just made my own Send method in SHKFacebook.m/h files, I think it will help you.
-(BOOL) sendWithImage :(NSString*)creativeUrl
{
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),
creativeUrl,
SHKEncodeURL(item.URL)
];
dialog.defaultStatus = item.text;
dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
SHKEncode(SHKMyAppName),
SHKEncode(SHKMyAppURL)];
[dialog show];
return YES;
}
Here is How I Use it
SHKFacebook *fb =[[SHKFacebook alloc]init];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@iphone/photo?id=%d",[SplashViewController getBaseURL],[photoId intValue]]];
fb.item = [SHKItem URL:url title:[dicResult valueForKey:@"Caption"]];
//fb.shareType = SHKShareTypeURL;
fb.quiet = YES;
[TedryUITabBarController updateProgress:10 totalByteToSent:11 message:@"Sharing on facebook"];
[fb sendWithImage:[dicResult valueForKey:@"CreativeURL"] :@""];
This may be slightly simpler, I hope, for those having problems with other answers here (although basically the same in principle).
Add the custom values to your item, such as:
[item setCustomValue:@"Your caption" forKey:@"caption"];
[item setCustomValue:@"Your description" forKey:@"description"];
[item setCustomValue:@"Your image URL" forKey:@"mediaSrc"];
[item setCustomValue:@"Your image link" forKey:@"mediaHREF"];
Note the two values needed for the image at the bottom: the source URL and the link URL. You then need to modify the "send" method in SHKFacebook.m to use those values, as follows:
// ...
if (item.shareType == SHKShareTypeURL)
{
self.pendingFacebookAction = SHKFacebookPendingStatus;
SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:");
// with image...
dialog.attachment = [NSString stringWithFormat:
@"{\
\"name\":\"%@\",\
\"href\":\"%@\",\
\"caption\":\"%@\",\
\"description\":\"%@\",\
\"media\":[\
{\
\"type\": \"image\",\
\"src\": \"%@\",\
\"href\": \"%@\"\
}]\
}",
item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
SHKEncodeURL(item.URL),
[item customValueForKey:@"caption"],
[item customValueForKey:@"description"],
[item customValueForKey:@"mediaSrc"],
[item customValueForKey:@"mediaHREF"]
];
dialog.defaultStatus = item.text;
dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
SHKEncode(SHKMyAppName),
SHKEncode(SHKMyAppURL)];
[dialog show];
}
// ...
And the link given by jumponadoughnut is the definitive list of fields you can use (I could not vote his up because my rep is not high enough): http://developers.facebook.com/docs/guides/attachments
I'm using the latest sharekit from github. Actually, you just set the url as the custom value of the link, with key "picture"
NSString *urlImage = @"http://someurl.com/someimage.jpg";
[linkItem setCustomValue:urlImage forKey:@"picture"];
It works for me.
SHKShareTypeURL = SHKShareTypeURL
and set item.URL
. Worked well for me. –
Decent You need to include a media url in the attachment json NSString found in the [SHKFacebook send:] implementation. See http://developers.facebook.com/docs/guides/attachments
© 2022 - 2024 — McMap. All rights reserved.