我想从 iphone 上传多张图片到 Facebook。而且我搜索了很多东西并制作了如下代码:但它不起作用。任何帮助将不胜感激。
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
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];
NSString *url1=@"http://uhallnyu.files.wordpress.com/2011/11/green-apple.jpg";
NSString *url2=@"http://scm-l3.technorati.com/12/04/24/67277/apple.gif?t=20120424140104";
NSData *data1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:url1]];
UIImage *img1 = [[UIImage alloc] initWithData:data1];
NSData *data2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:url2]];
UIImage *img2 = [[UIImage alloc] initWithData:data2];
[params setObject:img1 forKey:@"file1"];
[params setObject:img2 forKey:@"file2"];
[[delegate facebook] requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];