HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何从iphone sdk上传多个图像到Facebook大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想从 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 andhttpR_537_11845@ethod:@"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 andhttpR_537_11845@ethod:@"POST" andDelegate:self];

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

大佬总结

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

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。