2012-02-17 77 views
2

我在我的Cocoa应用程序中使用MGTwitterEngine库允许发送推文。通过可可应用程序使用MGTwitterEngine的Twitter:HTTP错误401

这里是我的代码:

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] 捕获点3(掷)2012-02-17 17:07:57.790梦想家[1853:1203] MGTwitterEngine:finalURL = http://api.twitter.com/1/statuses/update.xml

2012-02-17 17:07:57.791梦想家[1853:1203] MGTwitterEngine:finalBody =状态=叽叽喳喳%20post

[切换处理1853螺纹0x620b] 2012-02-17 18:30:38.491 Dreamer [2067:1203]请求连接失败标识符= DAAC2B20-91B6-49A6-90CA-4FD0606DA2FB,错误=操作无法完成。 (HTTP错误401)({ 体= “\ n \ n读取-唯一的应用程序不能发布\ n /1/statuses/update.xml\n\n”; 响应= “”;} )

Twitter上没有推文。

我注册了dev.twitter.com的应用程序,并把获得的Read, Write and Access direct messages

凡问题可能是什么?

回答

1

问题已解决。

如果有人将面临同样的问题,然后重新生成访问后更改您的访问令牌密钥

+0

http://stackoverflow.com/questions/4613727/iphone-why-i-got-this-error-http-error -401-叽叽喳喳 – 2012-10-25 13:34:39

相关问题