1
내 iOS 앱에 MGTwitterEngine
라이브러리를 사용하여 트윗을 게시합니다.iOS 용 MGTwitterEngine : 액세스 토큰을 얻는 방법? 오류 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"];
그러나 accessToken을 얻을 때까지는 트윗을 보낼 수 없습니다. 출력은 다음과 같습니다.
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' 메소드가 없습니다. –
그것의 인스턴스는 SA_OAuthTwitterEngine입니다. 이 클래스는 OAuth를'MGTwitterEngine' (OAuth가 아닌 곳) –