Facebook photos.upload crash in Facebook Api

泪湿孤枕 提交于 2019-12-25 04:56:15

问题


I need to upload photo on Facebook. But it seems to be impossible. I always have the same crash in console [UIImage dataUsingEncoding:] The way I get my Image:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissModalViewControllerAnimated:YES]; 
if ([mediaType isEqualToString:@"public.image"]){        
    _photoImage1 = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] retain];    

After all needed permissions:

-(void)uploadPhotoToFacebook {  
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:_photoImage1 forKey:@"image"];   
[args setObject:@"hello test picture" forKey:@"caption"];     
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:@"photos.upload" params:args];

It has crash after such a method in FBRequest.m

- (void)utfAppendBody:(NSMutableData*)body data:(NSString*)data {
[body appendData:[data dataUsingEncoding:NSUTF8StringEncoding]];

} Thanks in advance.


回答1:


Try to add image as dataParam

NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
[params setObject:@"NAME" forKey:@"caption"];     
[[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:params dataParam:UIImagePNGRepresentation(_photoImage1)];



回答2:


thats't work right for me

NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
[params setObject:@"NAME" forKey:@"caption"];     
[[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:params dataParam:UIImagePNGRepresentation(_photoImage1)];


来源:https://stackoverflow.com/questions/3990433/facebook-photos-upload-crash-in-facebook-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!