使用FHSTwitterEngine发布图像时出错 [英] Getting error while posting image using FHSTwitterEngine

查看:125
本文介绍了使用FHSTwitterEngine发布图像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我集成了FHSTwitterEngine,用于在Twitter上发布图像。直到上周,它运作良好。但突然间,在尝试发布图像时显示204错误

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 204 Error

Domain = FHSErrorDomain Code = 204请求未返回任何内容。

我不认为这是重复帖子的问题,因为图片会根据用户选择和第一次尝试发布图片时发生变化本身它给出了错误。

i don't think that it is an issue with duplicate post, because image will change according to user selection and while trying to post image first time itself it is giving the error.

基于文本的推文工作正常。问题是仅发布图片

Text based tweets are working properly. problem is with image posting only

我正在使用的代码

dispatch_async(GCDBackgroundThread, ^{
    @autoreleasepool {

        NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:self.textToTweet withImageData:UIImagePNGRepresentation(tweetImg)];

        NSString *title = nil;
        NSString *message = nil;

        if (returnCode) {
            NSLog("Error-->%d",returnCode.code);               
        } else {
            title = @"Tweet Posted";
            message = @"Successfully";
        }
     }
});

提前致谢

推荐答案

这是一个格式错误的多部分表格数据问题。

It's a malformed multipart form data problem.

看看FHSTwitterEngine.m。

Take a look at FHSTwitterEngine.m.

寻找这些行

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

在它下面添加这些行

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;

并添加此

params[@"status"] = tweetString;

或者你可以在这里得到修正:
https://github.com/alvani/FHSTwitterEngine/blob/master/FHSTwitterEngine/FHSTwitterEngine.m

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

谢谢。

这篇关于使用FHSTwitterEngine发布图像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆