Skip to content

Instantly share code, notes, and snippets.

@nst
Created December 20, 2013 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nst/8052682 to your computer and use it in GitHub Desktop.
Save nst/8052682 to your computer and use it in GitHub Desktop.
Use STTwitter to access direct messages with web-based authentication and reverse authentication
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:CONSUMER_KEY
consumerSecret:CONSUMER_SECRET];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
successBlock:^(NSString *oAuthToken,
NSString *oAuthTokenSecret,
NSString *userID,
NSString *screenName) {
STTwitterAPI *x = [STTwitterAPI twitterAPIWithOAuthConsumerKey:CONSUMER_KEY
consumerSecret:CONSUMER_SECRET
oauthToken:oAuthToken
oauthTokenSecret:oAuthTokenSecret];
[x getDirectMessagesSinceID:nil count:10 successBlock:^(NSArray *messages) {
NSLog(@"-- %@", messages);
} errorBlock:^(NSError *error) {
NSLog(@"-- error: %@", [error localizedDescription]);
}];
} errorBlock:^(NSError *error) {
NSLog(@"-- error: %@", [error localizedDescription]);
}];
} errorBlock:^(NSError *error) {
NSLog(@"-- error: %@", [error localizedDescription]);
}];
} errorBlock:^(NSError *error) {
NSLog(@"-- error: %@", [error localizedDescription]);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment