在Facebook上使用批量请求上传多张照片 [英] Upload multiple photos on Facebook using Batch Request

查看:376
本文介绍了在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.

这篇关于在Facebook上使用批量请求上传多张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆