我可以使用以下代码与facebook分享文字,图片和网址。
_lblTitle.text=@"Joe just ran 3.10 miles on the Niagara Falls 5k in 24.53 with http://www.outsideinteractive.com";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
_lblTitle.text, @"name",
data, @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog([NSString stringWithFormat:@"result: %@", result]);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog([NSString stringWithFormat:@"%@", error.description]);
}
}];
但现在我想分享超链接(带链接的文字)。
示例: Joe凭借Outside Interactiive在24.53的虚拟尼亚加拉大瀑布5k球场上跑了3.10英里。
目前我可以像这样分享:
乔凭借http://www.outsideinteractive.com
注意:我也在当前功能中分享图片,我想继续这样做。
期望的结果:
答案 0 :(得分:0)
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
您可以制作这样的字典并将其传递给您的函数,该函数将包含您想要的内容
或类似的东西
FBShareDialogParams *params = [[FBShareDialogParams alloc] init];
params.link = [NSURL URLWithString:@"https://developers.facebook.com/docs/ios/share/"];
params.name = @"Sharing Tutorial";
params.caption = @"Build great social apps and get more installs.";
params.picture = [NSURL URLWithString:@"http://i.imgur.com/g3Qc1HN.png"];
params.description = @"Allow your users to share stories on Facebook from your app using the iOS SDK.";
答案 1 :(得分:0)
经过大量搜索,我得到了解决方案。这只能通过 Facebook Open Graph Story 来实现。
您必须使用Facebook Developer Website创建自定义Story,并将其与您的ios应用程序正确集成。
按照此link创建自定义故事。