0

我正在尝试将我的应用程序中的帖子分享到 facebook。当我在“图片”键中输入图像链接时,它工作正常,但当我提供我自己的一张图片以共享时,应用程序崩溃。这是我正在使用的代码

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Magic Photo from Abracadabra Snap!", @"name",@"Edit photos, move objects around,remove photo bombs", @"caption",@"Use  automatic object detector to select objects or make your own custom selection.Remove the unwanted objects or photobomb,or move objects around.Do crazy stuff with your pictures , save and share with friends.", @"description",@"http://www.arkhitech.com/abracadabra/", @"link",tempImageForFacebookShare, @"picture",nil];

// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
            if (error)
                {
                // An error occurred, we need to handle the error
                // See: https://developers.facebook.com/docs/ios/errors
                NSLog([NSString stringWithFormat:@"Error publishing story: %@", error.description]);
                }
            else {

                if (result == FBWebDialogResultDialogNotCompleted)
                {
                    // User cancelled.
                    NSLog(@"User cancelled.");
                }
            else
            {
                // Handle the publish feed callback
                NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

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

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

图像是 10*10 图像,错误是Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0xab7b900'. 请指导这个问题

4

2 回答 2

1

它不适用于 a UIImage,因为 Api 只允许strings:

图片: 确定与链接关联的预览图像。细绳

来源:图形 API 参考

参数为链接的picture预览图,不能上传。

于 2014-04-08T09:28:53.300 回答
-1

您的代码看起来有效,但您正在向UIImageFacebook 发送一个,它期望在其中包含一个NSArraywith UIImages

NSDictionary请按如下方式更改您的代码:

@[tempImageForFacebookShare], @"picture",

看看它是否解决了问题。

于 2014-04-08T09:17:17.270 回答