
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所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)