Getting error while posting image using FHSTwitterEngine

前端 未结 4 813
感情败类
感情败类 2021-01-17 01:12

In my app i integrated FHSTwitterEngine for posting images in twitter. Till last week it is working fine. But all of a sudden, while trying to post an image it is showing 20

相关标签:
4条回答
  • 2021-01-17 01:52

    You need post the string length below then 130 characters

    0 讨论(0)
  • 2021-01-17 01:55

    I was not be able to post image on Twitter, But Using this code now i am able to post the data with image to twitter.

    https://github.com/alvani/FHSTwitterEngine
    

    Simply replace your FHSTwitterEngine with this library.

    its simply added some Changes or bugs in the Library

    0 讨论(0)
  • 2021-01-17 02:01

    compress the existing image using this code...

    NSData *data = UIImageJPEGRepresentation(imageView.image, 0.6);
    
    0 讨论(0)
  • 2021-01-17 02:02

    It's a malformed multipart form data problem.

    Take a look at FHSTwitterEngine.m.

    Look for these lines

    - (NSError *)sendPOSTRequestForURL:(NSURL *)url andParams:(NSDictionary *)params
    ...
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n",key] dataUsingEncoding:NSUTF8StringEncoding]];        
    [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:data];
    

    Add these lines below it

    if ([obj isKindOfClass:[NSData class]]) {
        [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    }
    

    I also noticed that it has missing status params bug.
    Look for

    - (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData inReplyTo:(NSString *)irt {
    ...
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"media[]"] = theData;
    

    And add this

    params[@"status"] = tweetString;
    

    Or you could get the fixes here: https://github.com/alvani/FHSTwitterEngine/blob/master/FHSTwitterEngine/FHSTwitterEngine.m

    Thanks.

    0 讨论(0)
提交回复
热议问题