【发布时间】:2012-05-04 17:24:47
【问题描述】:
我参考以下link 完成了以下代码,以创建在 Facebook 中上传多张照片的批量请求。
我有一些解决方案可以通过Facebook graph API. 在 Facebook 上上传多张照片
代码:
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];
现在,当我运行此代码时,我得到了以下输出。
结果字典在 - (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";
}
);
}
)
我不知道这些文件是如何附加的。任何人都可以帮我解决这个问题。
我的代码有什么变化吗,请告诉我。
提前谢谢...
【问题讨论】:
-
这是我要上传到 Facebook 的 UIImage。
-
您是否尝试过访问此站点:developers.facebook.com/docs/reference/api/batch 看起来很有帮助希望这会有所帮助
-
亲爱的在这里提问之前我已经看过这个链接了..
-
它只适用于 file1 吗?
-
Mehul,如果你有解决方案,你能发表你的答案吗?
标签: iphone objective-c ipad facebook-graph-api