在Facebook上使用批量请求上传多张照片

在Facebook上使用批量请求上传多张照片

问题描述:

我已经参考以下链接创建批量请求,以在Facebook上上传多张照片。

I had done following code with reference to following link to create batch request for uploading multiple photos in Facebook.

我有一些解决方案可以通过这个 Facebook图形API

I had got some solution for uploading multiple photos on Facebook through this Facebook graph API.

CODE: / strong>

CODE:

    NSString *jsonRequest1 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 1\", \"attached_files\": \"file1\" }";
    NSString *jsonRequest2 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 2\", \"attached_files\": \"file2\" }";
    NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:jsonRequestsArray,@"batch",nil];
    [params setObject:UIImagePNGRepresentation(self.image1) forKey:@"file1"];
    [params setObject:UIImagePNGRepresentation(self.image2) forKey:@"file2"];
    [objFacebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];

现在,当我运行此代码时,我得到以下输出。

Now when I am running this code I got the following output.

中的结果字典 - (void)请求:(FBRequest *)请求didLoad:(id)result

(
        {
        body = "{\"error\":0,\"error_description\":\"File file1 has not been attached\"}";
        code = 400;
        headers =         (
                        {
                name = "HTTP/1.1";
                value = "400 Bad Request";
            },
                        {
                name = "Content-Type";
                value = "text/javascript; charset=UTF-8";
            }
        );
    },
        {
        body = "{\"error\":0,\"error_description\":\"File file2 has not been attached\"}";
        code = 400;
        headers =         (
                        {
                name = "HTTP/1.1";
                value = "400 Bad Request";
            },
                        {
                name = "Content-Type";
                value = "text/javascript; charset=UTF-8";
            }
        );
    }
)

我不知道这个文件如何附加..任何人都可以帮我找出这个问题。

I don't know how this files attached.. Can anyone help me to figure out this problem.

我的代码是否有任何改变,请让我知道。

Is there any change in my code then please let me know.

提前感谢...

我建议您在iOS 6中使用新的集成的Facebook API来做到这一点的Facebook的API: https://developer.apple.com/videos/wwdc/ 2012 /?id = 306 有一个金色的WWDC视频的所有社交任务。另外在iOS 6中使用新的API比使用Facebook更快。

I recommend you use the new integrated Facebook API's in iOS 6 to do this instead of Facebook's API: https://developer.apple.com/videos/wwdc/2012/?id=306 there's a golden WWDC video for all social tasks. Plus using the new API's in iOS 6 is MUCH faster then using Facebooks.