Wrapper for the initial OAuth authentication and general use of the access tokens - should be in main MGTwitter
License
kimptoc/MGTwitterEngine-1.0.8-OAuth-MyTwitter
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The licence for use of this code is the MIT licence, based on that is what OAuth uses and also there is very little code here, just a few lines to glue OAuth and MGTwitterEngine together. This is a quick hack to the MGTwitterEngine 1.0.8 by Matt Gemmell to provide OAuth support. I reccomend you DO NOT USE this, but instead look at the more complete sample project by Isaiah. http://github.com/yourhead/OAuth_ObjC_Test_App/tree/master Or the offical MGTwitterEngine, which has been updated for OAuth - https://github.com/mattgemmell/MGTwitterEngine. Although I am not sure if it handles the latest OAuth change relating to verifier/pincode, see below Also be aware of the late July 2009 changes around the verifier/signature - this blog entry has the fix: http://nullagenda.com/oauthconsumer-and-twitter-114 The change is largely to the initial authorisation, for which you use OAuth - see MyTwitter.h and then changes to MGTwitterEngine to use the OAuth Url Request object instead with the correct access details. Basically you use the OAuth code first to sort out the access tokens then you pass that in the MGTwitterEngine calls. The changes to MGTwitterEngine are for that purpose. Remember to set your Twitter key/secret in the MyTwitter.m file - in fact review that - this will need changing for your purposes. The cient/token/url details are probably as supplied when registering your app with twitter, here : http://twitter.com/oauth_clients/new . You need OAuth from Jon Crosby - http://code.google.com/p/oauthconsumer/ - note you also need to change this to handle the new oauth_verifier parameter, introduced in 1.0a of OAuth and now used by Twitter. See my comment at the end of this page http://code.google.com/p/oauthconsumer/wiki/UsingOAuthConsumer for details of the changes. MGTwitterEngine 1.0.8 with tweaks for OAuth - https://github.com/kimptoc/MGTwitterEngine-1.0.8-OAuth/tree And the classes from this project - MyTwitter - https://github.com/kimptoc/MGTwitterEngine-1.0.8-OAuth-MyTwitter/tree To use, do this: In some suitable part of your app, check if you have been authorized with Twitter for this client if (NO == [self.mytwitter isUserAuthorized]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp Setup!" message:[NSString stringWithFormat:@"To use this app, you need to authorise it with Twitter. Touch Continue to do so and Close when done."] delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil]; [alert show]; [alert release]; [self.mytwitter askForRequestToken]; // throw up a browser with the twitter authorize url page // I used the one provided by the mobclix analytics library, but that may not be to everyone's taste. [MyBrowser openRequest: [self.mytwitter authorizeURL]]; // wait for browser to be closed... } When the user closes the browser (need some kind of callback to this) - (void)browserClosed: (id) thing { // this method then goes back to twitter.com and gets the access token, as per OAuth spec. // user will get shown a pincode, you need to ask the user for this pincode, which is then passed to twitter in the ask for access_token call. } Once you have the pincode, ask for the access token // this token is then used in all subsequent twitter interactions to prove this is authorised client. [self.mytwitter askForAccessToken: pincode]; To send a tweet, you can do it via mytwitter, although the login stuff above means you don't need to: NSString* connId = [self.mytwitter sendUpdate:tweet];
About
Wrapper for the initial OAuth authentication and general use of the access tokens - should be in main MGTwitter
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published