如何从iphone sdk上传多个图像到Facebook

如何从iphone sdk上传多个图像到Facebook,第1张

概述我想从 iphone上传多个图像到Facebook.我搜索了很多东西并制作了如下代码:但它不起作用.任何帮助将不胜感激. AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];NSString *jsonRequest1 = @"{ \"method\": \"POST\", \" 我想从 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\",\"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];
解决方法 您可以使用以下方式将照片上传到Facebook:
您可以使用开关盒来读取图像文件中的图像类型,并使用UIImagePNGRepresentation,UIImageJPEGRepresentation等功能获取图像数据.

NSData *yourImageData= UIImagePNGRepresentation(yourImage);

初始化字典: –

NSMutableDictionary *mutableDictWithParam= [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Your text",@"message",yourImageWithData,@"theSource",nil];

最后发帖子: –

[facebook requestWithGraPHPath:@"/me/photos" andParams:mutableDictWithParam andhttpMethod:@"POST" andDelegate:self];

您可以循环播放多个图像.

总结

以上是内存溢出为你收集整理的如何从iphone sdk上传多个图像到Facebook全部内容,希望文章能够帮你解决如何从iphone sdk上传多个图像到Facebook所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1079314.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存