1
我正在使用我的iOS應用的MGTwitterEngine
庫發佈推文。iOS版MGTwitterEngine:如何獲取accessToken?錯誤401
NSString *username = dataBase.twiLog;
NSString *password = dataBase.twiPas;
NSString *consumerKey = cons_key;
NSString *consumerSecret = cons_secret;
// 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.
MGTwitterEngine *twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
twitterEngine setClearsCookies:YES];
[twitterEngine setUsesSecureConnection:NO];
[twitterEngine setConsumerKey:consumerKey secret:consumerSecret];
[twitterEngine setUsername:username password:password];
[twitterEngine sendUpdate: @"This message was sent via myApp for iOS"];
但是我不能發送推文,直到我getToken。這裏輸出:
Request failed for connectionIdentifier = 5E7C9D2E-1467-45EF-B748-CCBF8F211F8D, error = The operation couldn’t be completed. (HTTP error 401.) ({
body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <error>Could not authenticate you.</error>\n <request>/1/statuses/update.xml</request>\n</hash>\n";
response = "<NSHTTPURLResponse: 0x6e26a10>";
})
我該如何使用MGTwitterEngine發送推文? (沒有從dev.twitter.com手動獲取我的訪問令牌,因爲其他用戶也應該能夠從他們自己發送推文)
'_engine'是什麼類的對象? 'MGTwitterEngine'類沒有'isAuthorized'和'clearAccessToken'方法 – 2012-03-15 15:12:12
它的一個'SA_OAuthTwitterEngine'的實例。該類將OAuth引入「MGTwitterEngine」(非OAuth分支) – 2012-06-27 01:36:01