使用iPhone中的批量JSON流程在Facebook上传图像的问题?

时间:2012-12-11 13:09:30

标签: iphone ios facebook facebook-graph-api

现在我尝试使用批处理方法发送多个方法,所以我使用以下代码尝试使用FBGraph在Facebook上发送两个图像,

NSString *req01 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\", \"body\": \"message=MyMessageOnPhotoone\", \"attached_files\": \"myimagedata\"}";
NSString *req02 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\", \"body\": \"message=MyMessageOnPhototwo\", \"attached_files\": \"myimagedata\"}";
NSString *allRequests = [NSString stringWithFormat:@"[ %@, %@ ]", req01, req02];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:allRequests forKey:@"batch"];
[facebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];

批处理方法是,

curl 
–F  'access_token=…' \
-F  'batch=[{"method":"POST", \
          "relative_url":"me/photos", \
          "body":"message=My cat photo" \
          "attached_files":"file1" \
         },
         {"method":"POST", \
          "relative_url":"me/photos", \
          "body":"message=My dog photo" \
          "attached_files":"file2" \
         },
        ]’
     -F  'file1=@cat.gif' \
     -F 'file2=@dog.jpg' \
     https://graph.facebook.com

我收到了以下错误,

  (
    {
    my binary image encoded data
    code = 400;
    headers =         (
                    {
            name = "WWW-Authenticate";

           my binary image encoded data
        },
                    {
            name = "HTTP/1.1";
            value = "400 Bad Request";
        },
                    {
            name = "Cache-Control";
            value = "no-store";
        },
                    {
            name = "Content-Type";
            value = "text/javascript; charset=UTF-8";
        }
    );
},
    {

     myimage binary encoded data
    code = 400;
    headers =         (
                    {
            name = "WWW-Authenticate";
            myimageBinary encoded data
        },
                    {
            name = "HTTP/1.1";
            value = "400 Bad Request";
        },
                    {
            name = "Cache-Control";
            value = "no-store";
        },
                    {
            name = "Content-Type";
            value = "text/javascript; charset=UTF-8";
        }
    );
   }
  )

我无法纠正我的代码中的URL请求中的问题。

0 个答案:

没有答案