我参考以下链接完成了以下代码,以创建在Facebook上传多张照片的批量请求.
我有一些解决方案可以通过这个Facebook图形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];
Run Code Online (Sandbox Code Playgroud)
现在,当我运行此代码时,我得到以下输出.
结果词典 - (void)request:(FBRequest *)request didLoad:(id)result
(
{
body = "{\"error\":0,\"error_description\":\"File file1 has not been attached\"}"; …Run Code Online (Sandbox Code Playgroud)