Fb分享对话框,我可以简单地发布带描述的图片吗?

时间:2021-12-29 19:01:07

I'm trying to create a simple sharing function for my ios app. I wanna take advantage of the new sharing dialog (advantages like , tagging friends, add places,ecc..). What i wanna share is a photo ,a link to itunes app download, a description that comes from the ios app. I have tried the sharedialog, something like this:

我正在尝试为我的ios应用程序创建一个简单的共享功能。我想利用新的共享对话框(诸如标记朋友,添加地点,ecc等优点)。我想分享的是一张照片,一个指向itunes app下载的链接,一个来自ios应用程序的描述。我尝试过sharedialog,类似这样:

NSURL *url=[[NSURL alloc] initWithString:@"https://itunes.apple.com/it/app/myapplication"];
[FBDialogs presentShareDialogWithLink:url name:@"My app name" caption:@"" description:@"prefilled descriptiontest" picture:[NSURL URLWithString:@"http://www.example.com/image.jpg"] clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
    if(error) {
        // An error occurred, we need to handle the error
        // See: https://developers.facebook.com/docs/ios/errors

        UIAlertView *av = [[[UIAlertView alloc]
                            initWithTitle:@"Sorry :("
                            message:@"There's been a problem publishing your message. Please try again!"
                            delegate:self
                            cancelButtonTitle:@"Close"
                            otherButtonTitles:nil] autorelease];
        [av show];

    } else {
        // Success

        UIAlertView *av = [[[UIAlertView alloc]
                            initWithTitle:@"Published!"
                            message:@"Your post has been successfully published."
                            delegate:self
                            cancelButtonTitle:@"Close"
                            otherButtonTitles:nil] autorelease];
        [av show];
    }
}];

It works but i see my prefilled description only in share dialog, when i see the shared content on facebook i only see the description taken from the linked page. So i have tried this other solution, the photodialog :

它工作,但我只在共享对话框中看到我的预填充描述,当我在Facebook上看到共享内容时,我只看到从链接页面获取的描述。所以我尝试了另一种解决方案,即photodialog:

 UIImage *Image=[UIImage imageNamed:@"myphoto.jpg"];
// Open the image picker and set this class as the delegate
FBPhotoParams *params = [[FBPhotoParams alloc] init];

// Note that params.photos can be an array of images.  In this example
// we only use a single image, wrapped in an array.
params.photos = @[Image];



[FBDialogs presentShareDialogWithPhotoParams:params
                                 clientState:nil
                                     handler:^(FBAppCall *call,
                                               NSDictionary *results,
                                               NSError *error) {
                                         if (error) {
                                             NSLog(@"Error: %@",
                                                   error.description);
                                         } else {
                                             NSLog(@"Success!");
                                         }
                                     }];

In this way i can post a photo on my wall but the description parameter seems to be onlyread and i can't set any prefilled text. How i can do? There's a way to force the visualization of my description text in the sharelink dialog? Or there's a way to set a text in the photodialog? Or there another solution ?

通过这种方式,我可以在我的墙上发布照片,但描述参数似乎只是读取,我无法设置任何预填充文本。我该怎么办?有一种方法可以在sharelink对话框中强制显示描述文本吗?或者有一种方法可以在photodialog中设置文本?还是有其他解决方案?

1 个解决方案

#1


0  

The only solution seems to be to use only the web fallback:

唯一的解决方案似乎是只使用网络回退:

NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               name, @"name",
                               author, @"caption",
                               linkShare, @"link",
                               userImage, @"picture",
                               nil];

[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                   parameters:parameter
                                      handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                          if (error)
                                          {
                                              NSLog(@"Error publishing story: %@", error.description);
                                          }
                                          else
                                          {
                                              if (result == FBWebDialogResultDialogNotCompleted)
                                              {
                                                  NSLog(@"User cancelled.");
                                              }
                                              else
                                              {
                                                  NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                                                  NSLog(@"User login");

                                                  if (![urlParams valueForKey:@"post_id"])
                                                  {
                                                      NSLog(@"User cancelled post.");

                                                  }
                                                  else
                                                  {
                                                      NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                      NSLog(@"result %@", result);

                                                  }
                                              }
                                          }
                                     }];    

#1


0  

The only solution seems to be to use only the web fallback:

唯一的解决方案似乎是只使用网络回退:

NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               name, @"name",
                               author, @"caption",
                               linkShare, @"link",
                               userImage, @"picture",
                               nil];

[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                   parameters:parameter
                                      handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                          if (error)
                                          {
                                              NSLog(@"Error publishing story: %@", error.description);
                                          }
                                          else
                                          {
                                              if (result == FBWebDialogResultDialogNotCompleted)
                                              {
                                                  NSLog(@"User cancelled.");
                                              }
                                              else
                                              {
                                                  NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                                                  NSLog(@"User login");

                                                  if (![urlParams valueForKey:@"post_id"])
                                                  {
                                                      NSLog(@"User cancelled post.");

                                                  }
                                                  else
                                                  {
                                                      NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                      NSLog(@"result %@", result);

                                                  }
                                              }
                                          }
                                     }];