【问题标题】:Twitter via Cocoa App using MGTwitterEngine: HTTP error 401Twitter 通过 Cocoa App 使用 MGTwitterEngine:HTTP 错误 401
【发布时间】:2012-02-17 11:45:44
【问题描述】:

我在我的 Cocoa 应用程序中使用 MGTwitterEngine 库来允许发送推文。

这是我的代码:

    NSString *username = MyName;
    NSString *password = MyPass;

    NSString *consumerKey = ConsumerKey;;
    NSString *consumerSecret = ConsumerSecret;

    // Most API calls require a name and password to be set...
    if (! username || ! password || !consumerKey || !consumerSecret) {
        NSLog(@"You forgot to specify your username/password/key/secret in AppController.m, things might not work!");
        NSLog(@"And if things are mysteriously working without the username/password, it's because NSURLConnection is using a session cookie from another connection.");
    }

    // Create a TwitterEngine and set our login details.
    twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
    [twitterEngine setUsesSecureConnection:NO];
    [twitterEngine setConsumerKey:consumerKey secret:consumerSecret];

    [twitterEngine setUsername:username password:password];

    OAToken *token = [[OAToken alloc] initWithKey:tokenKey
                                  secret:tokenSecret];
    [twitterEngine setAccessToken:token];
    [twitterEngine sendUpdate:@"twitter post"];

它的构建没有任何错误。当我运行我的应用程序时,这会出现在输出中:

[切换到进程 1853 线程 0x0] Catchpoint 3 (throw) 2012-02-17 17:07:57.790 Dreamer[1853:1203] MGTwitterEngine: finalURL = http://api.twitter.com/1/statuses/update.xml

2012-02-17 17:07:57.791 Dreamer[1853:1203] MGTwitterEngine: finalBody = status=twitter%20post

[切换到进程 1853 线程 0x620b] 2012-02-17 18:30:38.491 Dreamer[2067:1203] ConnectionIdentifier = DAAC2B20-91B6-49A6-90CA-4FD0606DA2FB 的请求失败,错误 = 操作无法完成。 (HTTP 错误 401。)({ body = "\n\n 只读应用程序无法 POST\n /1/statuses/update.xml\n\n"; 响应 = ""; })

Twitter 中没有任何推文。

我在 dev.twitter.com 上注册了应用程序并将访问权限设置为 Read, Write and Access direct messages

问题可能出在哪里?

【问题讨论】:

    标签: macos cocoa twitter mgtwitterengine http-error


    【解决方案1】:

    问题已解决。

    如果有人遇到同样的问题,请在访问更改后重新生成您的访问令牌密钥

    猜你喜欢
    • 2017-02-07
    • 1970-01-01
    • 2014-06-01
    • 2019-02-24
    • 1970-01-01
    • 2012-07-19
    • 2014-02-11
    • 2016-04-24
    • 2016-06-04
    相关资源
    最近更新 更多