Yossi
Yossi

Reputation: 2535

share an image and text on facebook sdk v3.13

In older Facebook SDK I used the below code to enable the user to share a screenshot, and I added a text above the image that contains a link to the App.

The focus was on the screenshot and not on the link. In the latest SDK, I can't find a way to do so. In their tutorial they show how to share a link and add an image to the link frame, or how to share a photo but this is not what I want.

The most important thing to me is that the image I add to the post should be big, and I have to add a text and link above it (not text the user will add, but a text I am adding)

This is the code I used in older SDK version:

 NSDictionary * params = @{
     @"link"    : link,
     @"message" : strMessagetoPost,
     @"picture" : UIImageJPEGRepresentation(img, 1.0f)};

     [FBRequestConnection startWithGraphPath:@"me/photos"
     parameters:params
     HTTPMethod:@"POST"
     completionHandler:^(FBRequestConnection *connection,id result,NSError *error)
                     {
                     if (error) {
                     }
                     else {
                     }
     }];

Any idea how to do it with FBDialogs class or in any other way?

Upvotes: 0

Views: 490

Answers (2)

Giya
Giya

Reputation: 248

For sharing you can use Social Framework.Here is the code.

Add Social framework and use this header

#import <Social/Social.h>
-(void)ShareOnFacebook
{
    if([SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook])
    {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [controller setInitialText:@"Greetings"];
        [controller addImage:finalImage];

        [self presentViewController:controller animated:YES completion:Nil];
    }
}

It's work for me..Try it..

Upvotes: 0

Bhavesh Nayi
Bhavesh Nayi

Reputation: 3656

     NSString *str_link = [NSString stringWithFormat:@"%@uploads/%@-5.jpg",app.Main_url,[Data_Dict objectForKey:@"deal_id"]];
     //NSLog(@"%@",str_link);

     NSDictionary *params = @{
                              @"name" :[NSString stringWithFormat:@"%@",[Data_Dict objectForKey:@"name"]],
                              @"caption" : @"",
                              @"description" :[Data_Dict objectForKey:@"desc_title"],
                              @"picture" : str_link,
                              @"link" : @"",
                              };

     // Invoke the dialog
     [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                            parameters:params
                                               handler:
      ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
          if (error) {
              //NSLog(@"Error publishing story.");
              [self.indicator stopAnimating];
          } else {
              if (result == FBWebDialogResultDialogNotCompleted) {
                  //NSLog(@"User canceled story publishing.");
                  [self.indicator stopAnimating];
              } else {
                  //NSLog(@"Story published.");
                  [self.indicator stopAnimating];
              }
          }}];
 }

Upvotes: 2

Related Questions