Search code examples
iphonetwittermgtwitterengine

MGTwitterEngine (iPhone) won't send update to Twitter


I cant send status update on twitter.

Here is my code..

- (void) tweet{

_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
_engine.consumerKey = @"someKey";
_engine.consumerSecret = @"someSecret";

UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];

if (controller)
    [self presentModalViewController: controller animated: YES];
else {
    tweets = [[NSMutableArray alloc] init];
    [self updateStream:nil];
}

[_engine sendUpdate:@"test"];
[self updateStream:nil];

}


Solution

  • Try using in this way:

    - (void) tweet{
    
    
    _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
    _engine.consumerKey = @"someKey"; //So please make sure that you had replaced the keys over here.
    _engine.consumerSecret = @"someSecret";
    
    UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
    
    if (controller)
        [self presentModalViewController: controller animated: YES];
    else {
        tweets = [[NSMutableArray alloc] init];
       [_engine sendUpdate:[NSString stringwithFormat:@"Today Test Date is %@",[NSDate date]]]; // You will be able to post any tweet when you are successfully logged in.So post the message after login rather than 
       [self updateStream:nil];
    }
    }
    

    I am sure it would work for you....