1

I tried to post from twitter but it not posting the comments. It display an error 204 , in the facebook the same data is successfully posted but in the twitter i got an error can any one have an idea How to solve it

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!!!");
        }];
    }

}
nivritgupta
  • 1,966
  • 2
  • 20
  • 38

4 Answers4

0

Your comments made me smile.

I believe it's an HTML error. It means the data was received and understood but you shouldn't expect a return. In other words, it's void. At least that's what I can see with a quick look around your code and my minimal understanding of Twitter API.

Dr Ken Reid
  • 577
  • 4
  • 22
  • 2
    i find out the solution if the user post the same string again and again into their twitter account then Error 204 Occur because twitter does not allow to post the same message again and again – nivritgupta Sep 29 '13 at 12:28
0

Now i am able to send the String but cant able to send the Image using this method

 NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:theWholeString withImageData:imageData];
nivritgupta
  • 1,966
  • 2
  • 20
  • 38
  • hey @nivritgupta I am having same problem with this framework right now. could you tell the solution what you have done for resolving this issue??? Thanks in advance – Sumeet Mourya Feb 06 '14 at 06:43
  • @Mady if you trying to post the string length above then 130 word then this error will appear , because twitter SDK only supported 130 words through custom implemettation of twtter SDk , Later i have changed all the SDK after that i am able to solve this error , or try to post the string length within 130 words might be helpful – nivritgupta Feb 07 '14 at 18:35
0

FHSTwitterEngine has some known bugs, and the problem is now fixed, see below:
Getting error while posting image using FHSTwitterEngine

Community
  • 1
  • 1
0

compress the existing image with this code and you will get images posted.

NSData *data = UIImageJPEGRepresentation(imageView.image, 0.6);
Smit Shah
  • 209
  • 2
  • 9