Search code examples
iphonetwittermgtwitterengine

How to send direct message using MGTwitterEngine


I want to send direct message to my Twitter followers using https://api.twitter.com/1/direct_messages/new.format but not getting how to do this. does any one can provide me any sample code for this ?

I have search a lot for this but not getting How I will get these values :

oauth_nonce, oauth_signature, oauth_signature_method, oauth_timestamp, oauth_token.

Thank in Advance


Solution

  • Here is how to send Direct message using Twitter Engine

      appDelegate._engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
            appDelegate._engine.consumerKey = kOAuthConsumerKey;
            appDelegate._engine.consumerSecret = kOAuthConsumerSecret;
    

    once you get authenticated this method get called

      #pragma mark SA_OAuthTwitterControllerDelegate
    
        - (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *)username {
         NSLog(@"Authenicated for %@", username);
         [appDelegate._engine sendDirectMessage:@"Test for Twitter direct message" to:username];
    }