我可以使用以下代码与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在24.53的尼亚加拉大瀑布5k上跑了3.10英里

注意:我还在当前功能中共享图片,并且我想继续。

所需结果:

最佳答案

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.";

关于ios - 通过iOS应用与Facebook分享超链接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22088022/

10-11 22:46