【问题标题】:How to send direct message with Twitter?如何使用 Twitter 发送直接消息?
【发布时间】:2011-05-08 09:09:03
【问题描述】:

在我的 iphone 应用程序中,我必须通过 twitter 发送直接消息, 问题是 twitter 已将身份验证从基本身份验证更改为 oauth 网上的教程已经过时了

所以我使用 SAOauthTwitterEngine 作为身份验证部分,一切正常。但是这些类不使用 api,所以我必须为此使用 MGTwitterEngine。

问题是 MGTE 没有 oauth,只有 xauth 和基本身份验证,我不能一起使用,有人知道怎么做吗?或者知道一个解释它的教程。

非常感谢。

【问题讨论】:

    标签: iphone objective-c oauth twitter mgtwitterengine


    【解决方案1】:

    我建议您使用 OAuth,因为 xAuth 要求您向 twitter 发送一封电子邮件,要求他们授予您权限,并且您必须在您的应用程序上写一个 reort(这对于测试应用程序来说并不好) 你试过这个吗? https://github.com/bengottlieb/Twitter-OAuth-iPhone

    【讨论】:

    • 是的,我使用 oauth,我还没有测试这个例子,我会尽快尝试
    • 我已经尝试过了,但这仅实现了身份验证部分,与 api 无关
    【解决方案2】:

    在我的应用程序中,我使用 MGTwitterEngine 向我的 Twitter 关注者发送直接消息让我们看看:

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

    一旦你获得认证,这个方法就会被调用

        #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];
    }
    

    希望这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2020-07-14
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-01
      • 2012-05-02
      • 2018-07-22
      • 2020-09-10
      相关资源
      最近更新 更多