Twitter tramite Cocoa App utilizzando MGTwitterEngine: errore HTTP 401
-
27-10-2019 - |
Domanda
Io uso biblioteca MGTwitterEngine
nella mia applicazione Cocoa per consentire l'invio di tweet.
Ecco il mio codice:
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"];
Si costruisce senza errori. Quando eseguo la mia applicazione ciò si verifica in uscita:
[Commutazione di elaborare 1.853 filo 0x0] Catchpoint 3 (tiro) 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
[Commutazione di elaborare 1853 filo 0x620b] 2012-02-17 18: 30: 38,491 Dreamer [2067: 1203] Richiesta non riuscita per connectionIdentifier = DAAC2B20-91B6-49A6-90CA-4FD0606DA2FB, errore = L'operazione non ha potuto essere completato. (HTTP errore 401.) ({ corpo = "\ n \ n sola lettura applicazione non può POST \ n /1/statuses/update.xml\n\n"; risposta = ""; })
e non appaiono tweet twitter.
I registrata l'applicazione su dev.twitter.com e l'accesso mettere come Read, Write and Access direct messages
Se il problema potrebbe essere?
Soluzione
Problema risolto.
Se qualcuno si troveranno ad affrontare lo stesso problema quindi rigenerare l'accesso token di chiave dopo che l'accesso cambiando