Monday, June 24, 2013 - 01:28

Twitter and OAuth. If your inbound tweets aren't working ... again.

I just love Twitter for changing their API for no particular reason than angering me personally. Usually I just dismiss it until I actually need it again. This time however a customer required it and that meant I had to deal with it.

Usually there's a temprary workaround for these kind of creative API changes and there is again. Like this one here. However they are all a bit shady and the official way isn't really that hard to implement. If you're on the PHP side of the pond. There's a library called tmhOAuth over at github ( requires curl ).

All you really have to do is create an app @twitter for your website. And then feed that data into the tmhOAuth class. It requires little code changes. You can create user_token and user_secret together with the app.


	require 'tmhOAuth.php';
	$tmhOAuth = new tmhOAuth( array(
				'consumer_key'    => 'CONSUMER_KEY',
				'consumer_secret' => 'COMSUMER_SECRET',
				'user_token'      => 'USER_TOKEN',
				'user_secret'     => 'USER_SECRET',
	$code = $tmhOAuth->request( 'GET', $tmhOAuth->url('1.1/statuses/user_timeline' ), array( 'screen_name' => SCREEN_NAME, 'count' => NUMBER_OF_TWEETS ) );
	$response = $tmhOAuth->response;
$response is an array that has a field 'response'. It contains your feeds as json encoded array.

The work - in this case - is rather assessable and you should stay away from custom solutions that don't match the API and are usually harder to implement in the first place. It's still a nuisance but it's one that is quickly fixed...this time.