开发者

Facebook photos.upload crash in Facebook Api

开发者 https://www.devze.com 2023-01-21 07:53 出处:网络
I need to upload photo on Facebook. But it seems to be impossible. I always have the same crash in console [UIImage dataUsingEncoding:]

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"]){        
    _phot开发者_如何学JAVAoImage1 = [[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.


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)];


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)];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号