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

查看:40
本文介绍了使用批量请求在 Facebook 上上传多张照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参考了以下链接 创建批量请求以在 Facebook 上传多张照片.

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

我有一些解决方案可以通过这个 Facebook 图形 API 在 Facebook 上上传多张照片.

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

代码:

    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.

Result Dictionary in - (void)request:(FBRequest *)request 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天全站免登陆