Hi guys! I recently am working on my game and I want to put a feature in to let people update their twitter account with news like "Hey I got 520 score!". The thing is, Twitter used to be easy to connect to but they are changing it so everyone MUST use their OAuth authentication method in 9 weeks. This means many current apps updating to Twitter will not work! (reference): http://mashable.com/2010/04/24/twitter-oauthcalypse/ )
So I found the Twitter-OAuth-iPhone project that Ben Gottlieb made and it looks good. Only 2 problems: (A) I am terrible programmer and (B) this library uses view controllers a lot I think.
So I made an effort to figure this out cause I think a HOWTO would be really good for the community. More people twittering about Cocos2d games is my kind of twitter! So I am putting a HOWTO together on making this work with a default Cocos2d project, maybe everyone could chime in if I make mistakes or to extend this, so everyone who needs to update their games with new twitter OAuth can be helped! I have so far:
-------------------------------------
to set up Twitter-OAuth-iPhone with a Cocos2D project:
- download the software from http://github.com/bengottlieb/Twitter-OAuth-iPhone
- you will find a folder in there called "Twitter+OAuth". You import this Twitter+OAuth folder into your project using "Add to Project"
- add /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/usr/lib/libxml2.dylib also using "Add to Project"
- add /usr/include/libxml2/ to header search paths in PROJECT MENU >> EDIT PROJECT SETTINGS >> BUILD TAB
- import the OAuthTwitterDemoViewController .h and .m and .xib files from the DEMO folder of the Twitter-OAuth-iPhone folder you downloaded
- enter consumer key and consumer secret in the OAuthTwitterDemoViewController.m
#define kOAuthConsumerKey @"S" //REPLACE ME
#define kOAuthConsumerSecret @"E" //REPLACE ME
- In your project's AppDelegate .m implementation file, go to the bottom of the applicationDidFinishLaunching method and put this in:
---------
[[CCDirector sharedDirector] attachInView:window];
OAuthTwitterDemoViewController *aViewController = [[OAuthTwitterDemoViewController alloc]
initWithNibName:@"OAuthTwitterDemoViewController" bundle:[NSBundle mainBundle]];
[self setViewController:aViewController];
[aViewController release];
[[[CCDirector sharedDirector] openGLView] addSubview:aViewController.view];
//UIView *controllersView = [aViewController view];
//[window addSubview:controllersView];
[window makeKeyAndVisible];
----
So right now you have the program working so when you launch your new app, it pops open a view controller which will either log you into twitter OR post a post to your twitter if you are already logged in.
Let's make this more helpful, can anyone give code samples from here in maybe so instead of logging you in OR posting, it does BOTH, like logs you in and then updates?
How can we make this easier for people to work into their projects? I am all ears!