【问题标题】:Sharing hyperlink with facebook from iOS app从 iOS 应用程序与 facebook 共享超链接
【发布时间】:2014-04-01 00:48:40
【问题描述】:

我可以使用以下代码与 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 刚刚在 24.53 的 Virtual Niagara Falls 5k Course 上跑了 3.10 英里,Outside Interactiive

目前我可以这样分享:
Joe 刚刚在 24.53 在 Niagara Falls 5k 上跑了 3.10 英里,http://www.outsideinteractive.com

注意:我也在分享当前功能的图片,我想继续。

期望的结果:

【问题讨论】:

  • 你是怎么解决这个问题的。请分享解决您问题的代码或链接。我必须做同样的任务。但找不到有用的链接。我尝试使用 html 字符串但未能成功。

标签: ios iphone objective-c facebook facebook-graph-api


【解决方案1】:
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.";

【讨论】:

  • thanx,但我已经尝试过这种方式。我得到的结果就像我在“不想这样分享”标签下的问题中添加的那样。还有什么办法吗?
【解决方案2】:

经过大量搜索,我得到了解决方案。只有 Facebook Open Graph Story 才能做到这一点。

您必须使用 Facebook 开发者网站创建自定义故事,并将其与您的 ios 应用程序正确集成。

关注此link 以创建自定义故事。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多