我在我的iPhone应用程序中使用sharekit在Facebook上共享URL链接。但是,在我看来,不可能通过sharekit与图像共享url。你们知道该怎么做吗?非常感谢。如何在Facebook上通过ShareKit上的图像发布URL
10
A
回答
3
您需要在[SHKFacebook发送:]实现中找到的附件json NSString中包含媒体网址。请参阅http://developers.facebook.com/docs/guides/attachments
11
请看看我刚在SHKFacebook.m/h文件中创建自己的发送方法的代码,我认为它会对您有所帮助。
-(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;
}
这里是我如何使用它
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"] :@""];
4
我使用的是从GitHub最新sharekit。其实,你只需将网址设置为链接的自定义值,使用关键“图片”
NSString *urlImage = @"http://someurl.com/someimage.jpg";
[linkItem setCustomValue:urlImage forKey:@"picture"];
它适用于我。
5
对于那些在这里遇到其他问题的人来说,这可能会稍微简单一些(尽管原则上基本相同)。
添加自定义值到你的项目,如:源地址和链接网址:
[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"];
注意需要在底部的图像的两个值。然后,您需要修改SHKFacebook.m“发送”的方法来使用这些值,如下所示:
// ...
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];
}
// ...
而且通过jumponadoughnut 给出的链接是字段定义列表,你可以使用(我做不到投票他,因为我的代表不够高):http://developers.facebook.com/docs/guides/attachments
相关问题
- 1. Sharekit API:无法发布在Facebook墙上
- 2. 在Facebook上发布图像
- 3. 如何在iPhone上的Facebook上发布图像和视频
- 4. 的Facebook就像在iPhone上sharekit
- 5. 在Facebook上发布图像iOS
- 6. 上传图像通过URL
- 7. 更改Facebook图标,当通过Facebook API发布在墙上时
- 8. ShareKit - 发帖链接图像的Facebook墙上
- 9. ShareKit:你怎么能发布在你的Facebook朋友的墙上?
- 10. 如何在facebook上使用C#facebook sdk在codeplex上发布图像
- 11. 使用ShareKit发布图片至Facebook
- 12. 在Facebook上发布大图
- 13. 图片在Facebook上发布?
- 14. 在facebook上发布图片
- 15. Facebook - 如何通过URL上传照片?
- 16. 通过图形API在fb墙上发布图像的问题?
- 17. iPhone - 使用Sharekit向Facebook发送图像
- 18. 如何通过iOS应用在Facebook上发布信息?
- 19. 如何通过iPhone应用程序在Facebook上发布照片?
- 20. 如何使用iOS中的Sharekit直接在Facebook或Twitter上发布
- 21. 如何在Facebook上使用最新的Facebook SDK发布图片和url
- 22. Facebook - 通过图表API在页面上发布预定帖子
- 23. MISSING_ARG_APIKEY当通过Sharekit发布到twitter时
- 24. 如何通过windows phone中的代码在Facebook上发布图片?
- 25. 如何通过Windows Phone将图像发布到Facebook?
- 26. 如何通过Facebook Messenger Send API发送在Amazon S3上托管的图像?
- 27. 发布在facebook墙上,就像
- 28. 通过网址在Google+上发布图像
- 29. 如何在使用javascript的Phonegap上的twitter上发布图像
- 30. 如何在ez上应用vignette图像magick过滤器发布
好的回复,非常有帮助 – justicepenny 2011-02-21 09:45:01
scompt,你能帮我开始你的代码吗?该项目在哪里?我以为sharekit是关于这个项目的......我怎么称呼sendWithImage - 你能展示一个样本吗?谢谢! – 2011-04-21 08:45:47
你错过了你的代码大块,所以它是不可能工作你已经解决了它 – daidai 2011-09-29 13:05:06