错误204,请求在向Twitter发布数据时未返回任何内容

时间:2013-09-26 09:08:53

标签: iphone ios objective-c xcode twitter

我试图从Twitter发帖但是没有发表评论。它显示错误204,在facebook中相同的数据成功发布但在twitter中我得到一个错误可以任何人有一个想法如何解决它

enter image description here

-(void)postDataOnTwitterMethod{

    if ([[FHSTwitterEngine sharedEngine]isAuthorized]) {
        NSData *dataFromPath = UIImageJPEGRepresentation(cameraImage,1.0);

        number = (arc4random()%10000)+1; //Generates Number from 1 to 10000.
        RndNo = [NSString stringWithFormat:@"%i", number];
        NSLog(@" ITEM %@",RndNo);

        NSString *avalabelDate = [NSString stringWithFormat:@"%@_%@",[CommonMethods getCurrentDateAndTime],self.AvailableTillTextField.text];

        NSString *theWholeString = [NSString stringWithFormat:@"Item No: %@\nItemName: %@\nItemCost: %@\nAvailableTill: %@\nCategory: %@\nDescription: %@",RndNo,self.NameTextField.text,self.PriceTextField.text,avalabelDate,self.ListTypeTextField.text,self.DecTextView.text];

        dispatch_async(GCDBackgroundThread, ^{
            @autoreleasepool {

                [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
                NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:theWholeString withImageData:dataFromPath];
                [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";
                }
                dispatch_sync(GCDMainThread, ^{
                    @autoreleasepool {
                        UIAlertView *av = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                        [av show];
                    }
                });
            }
        });
    }
    else{
        [[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) {
            NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
        }];
    }

}

4 个答案:

答案 0 :(得分:0)

你的评论让我微笑。

我认为这是一个HTML错误。这意味着数据已被接收和理解,但您不应期待返回。换句话说,它是无效的。至少我可以通过快速查看代码以及对Twitter API的最小理解来看到这一点。

答案 1 :(得分:0)

现在我能够发送字符串,但无法使用此方法发送图像

 NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:theWholeString withImageData:imageData];

答案 2 :(得分:0)

FHSTwitterEngine有一些已知的错误,问题现已解决,见下文:
Getting error while posting image using FHSTwitterEngine

答案 3 :(得分:0)

使用此代码压缩现有图像,您将发布图像。

NSData *data = UIImageJPEGRepresentation(imageView.image, 0.6);