gpt4 book ai didi

ios - Facebook 批量照片上传 iOS

转载 作者:技术小花猫 更新时间:2023-10-29 10:17:42 28 4
gpt4 key购买 nike

我在尝试让 Facebook iOS SDK 批量上传照片时遇到了一些问题。目前我可以一个一个上传,但如果可能的话我想批量处理请求。我读过这个post over and over连同 fb batch docs .这是我到目前为止所拥有的。

 Facebook *facebook = [(AppDelegate*)[[UIApplication sharedApplication] delegate] facebook]; 

NSData *imageData = UIImagePNGRepresentation([imgs objectAtIndex:0]);
NSString *jsonRequest1 = [NSString stringWithFormat:@"{ \"method\": \"POST\", \"relative_url\": \"me/photos\", \"attached_files\": \"file1\" }"];
NSString *jsonRequest2 = [NSString stringWithFormat:@"{ \"method\": \"POST\", \"relative_url\": \"me/photos\", \"attached_files\": \"file2\" }"];
NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];


NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:jsonRequestsArray,@"batch",imageData,@"file1",imageData,@"file2" nil];

我正在将 imageData 映射到它正在寻找的键,但我每次都会收到此响应。

  {
body = "{\"error\":{\"message\":\"File batch has not been attached\",\"type\":\"GraphBatchException\"}}";
code = 400;
headers = (
{
name = "WWW-Authenticate";
value = "OAuth \"Facebook Platform\" \"invalid_request\" \"File batch has not been attached\"";
},
{
name = "HTTP/1.1";
value = "400 Bad Request";
},
{
name = "Cache-Control";
value = "no-store";
},
{
name = "Content-Type";
value = "text/javascript; charset=UTF-8";
}
);
},
{
body = "{\"error\":{\"message\":\"File file2 has not been attached\",\"type\":\"GraphBatchException\"}}";
code = 400;
headers = (
{
name = "WWW-Authenticate";
value = "OAuth \"Facebook Platform\" \"invalid_request\" \"File file2 has not been attached\"";
},
{
name = "HTTP/1.1";
value = "400 Bad Request";
},
{
name = "Cache-Control";
value = "no-store";
},
{
name = "Content-Type";
value = "text/javascript; charset=UTF-8";
}
);
}
)

非常感谢任何帮助。

最佳答案

您是否尝试过使用适用于 iOS 6 的社交框架来分享照片?它允许您添加所有照片并共享它们。

- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

[controller setInitialText:@"First post from my iPhone app"];
[controller addURL:[NSURL URLWithString:@"http://www.jinibot.com"]];
[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];

//add as many images as you want
[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];
[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];
[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];

[self presentViewController:controller animated:YES completion:Nil];
}
}

关于ios - Facebook 批量照片上传 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8749859/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com