我在我的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
凡問題可能是什麼?
http://stackoverflow.com/questions/4613727/iphone-why-i-got-this-error-http-error -401-嘰嘰喳喳 – 2012-10-25 13:34:39