SDK无法从ios应用程序发布图片

SDK无法从ios应用程序发布图片

本文介绍了Facebook SDK无法从ios应用程序发布图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在Facebook上发布照片.

I am using the following code to post photo on facebook.

if ([FBDialogs canPresentShareDialogWithPhotos])
{


    FBShareDialogPhotoParams *params = [[FBShareDialogPhotoParams 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 = @[imageDetails.chosenImage];
    params.place=@"Abracadabra Snap! ios application";
    [FBDialogs presentShareDialogWithPhotoParams:params
                                     clientState:nil
                                         handler:^(FBAppCall *call,
                                                   NSDictionary *results,
                                                   NSError *error) {
                                             if (error) {
                                                 NSLog(@"Error: %@",
                                                       error.description);
                                             } else {
                                                 NSLog(@"Success!");
                                             }
                                         }];
}

它显示了一个对话框,我在其中写一些文本并单击post,然后单击post之后,它将上载图像并返回到调用控制器,但不会返回错误或成功,也不会发布图像在facebook上.请为这个问题提供帮助

It shows me a dialog where I write some text and click on post, and after I click post, it uploads the image and comes back to the calling controllers, but does not return either error or success and doesn't post the image on facebook either. Please help about this problem

推荐答案

在共享按钮中尝试此...

TRY THIS ...in Share Button......

- (IBAction)facebookPost:(id)sender
{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {

        SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [mySLComposerSheet setInitialText:@"ABC"];

        [mySLComposerSheet addImage:[UIImage imageNamed:@"abc.png"]];

        [mySLComposerSheet addURL:[NSURL URLWithString:@"google.com"]];

        [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result)
        {

            switch (result)
            {
                case SLComposeViewControllerResultCancelled:
                {
                    NSLog(@"Post Canceled");
                    break;
                }

                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Post Sucessful");
                    break;
                }

                default:
                    break;
            }
        }];

        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
    }
}

这篇关于Facebook SDK无法从ios应用程序发布图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 19:07