Reputation: 12293
I use MGTwitterEngine
library in my Cocoa application to allow sending tweets.
Here's my code:
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"];
It builds without any errors. When I run my app this occurs in output:
[Switching to process 1853 thread 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
[Switching to process 1853 thread 0x620b] 2012-02-17 18:30:38.491 Dreamer[2067:1203] Request failed for connectionIdentifier = DAAC2B20-91B6-49A6-90CA-4FD0606DA2FB, error = The operation couldn’t be completed. (HTTP error 401.) ({ body = "\n\n Read-only application cannot POST\n /1/statuses/update.xml\n\n"; response = ""; })
And no tweets appear in Twitter.
I registered the application on dev.twitter.com and put access as Read, Write and Access direct messages
Where the problem may be?
Upvotes: 2
Views: 655
Reputation: 12293
Issue solved.
If someone will face the same problem then regenerate your access token key after access changing
Upvotes: 1