Sharing hyperlink with facebook from iOS app
Asked Answered
M

2

4

I am able to share text, picture and url with facebook using following code.

_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.

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

Note:I am also sharing picture in current functionality, And I want to continue with that.

Desired Result: enter image description here

Mayonnaise answered 28/2, 2014 at 6:39 Comment(1)
how did you solve this. pleas share the code or link which solves your problem. I have to do the same task. but could not find a helpful link. I tried to work with html string but could not succeed.Paregmenon
V
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];

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.";
Veriee answered 28/2, 2014 at 6:56 Comment(1)
thanx, but I have already tried this way. And I am getting result like I have added in my question under tag "Dont want to share like this". Any other way?Mayonnaise
M
0

After searching a lot I got the solution. This is possible only by Facebook Open Graph Story.

You will have to create custom Story using Facebook Developer Website and integrate it properly with your ios app.

Follow this link to create custom story.

Mayonnaise answered 6/8, 2014 at 6:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.