FHStwitterEngineで画像を投稿するとエラーが返されますが、imahe なしでツイートすると、正常に投稿されます
-(void)postTweet:(NSString*)message withImage:(UIImage*)img {
dispatch_async(GCDBackgroundThread, ^{
@autoreleasepool {
NSString *strMsg =[NSString stringWithFormat:@"%@",message];
NSData *imgData =UIImagePNGRepresentation(img);
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:strMsg withImageData:imgData];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSString *title = nil;
NSString *message = nil;
if (returnCode) {
title = [NSString stringWithFormat:@"Error %d",returnCode.code];
message = returnCode.localizedDescription;
} else {
title = @"Tweet Posted";
message = message;
}
dispatch_sync(GCDMainThread, ^{
@autoreleasepool {
UIAlertView *av = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[av show];
}
});
}
});
}
- (IBAction)btnPost:(id)sender {
NSString *str =@"Test5";
UIImage *image =[UIImage imageNamed:@"contact.png"];
if (image ==nil) {
[self postTweet:str];
}else {
[self postTweet:str withImage:image];
}
}