简体   繁体   English

从iOS应用程序与Facebook共享超链接

[英]Sharing hyperlink with facebook from iOS app

I am able to share text, picture and url with facebook using following code. 我可以使用以下代码与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]);
                            }
                          }];

But now I want to share hyperlink (text having link). 但现在我想分享超链接(带有链接的文本)。

Example: Joe just ran 3.10 miles on the Virtual Niagara Falls 5k Course in 24.53 with Outside Interactiive . 示例: Joe在24.53的虚拟尼亚加拉大瀑布5k球场上跑了3.10英里外线互动

Currently I am able to share like this: 目前我能够像这样分享:
Joe just ran 3.10 miles on the Niagara Falls 5k in 24.53 with http://www.outsideinteractive.com 乔凭借http://www.outsideinteractive.com在24.53的尼亚加拉瀑布5k跑了3.10英里

Note:I am also sharing picture in current functionality, And I want to continue with that. 注意:我也在当前功能中共享图片,我想继续这样做。

Desired Result: 期望的结果: 在此输入图像描述

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];

You can make a dictionary like this and pass this to your function which will contain what exactly you want 您可以制作这样的字典并将其传递给您的函数,该函数将包含您想要的内容

Or something like this 或类似的东西

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

After searching a lot I got the solution. 经过大量搜索,我得到了解决方案。 This is possible only by Facebook Open Graph Story . 这只能通过Facebook Open Graph Story实现

You will have to create custom Story using Facebook Developer Website and integrate it properly with your ios app. 您必须使用Facebook Developer Website创建自定义Story,并将其与您的ios应用程序正确集成。

Follow this link to create custom story. 点击此链接创建自定义故事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM