oauth twitter posting

I noticed Twitter do not support Basic HTTP Auth but oAuth, so I had a look around at the available libraries and EPITwitter by Jaisen Mathai works fine as replacement for cUrl http auth.

I noticed when testing it with Twitter the whole key set is stored on the dev.twitter subdomain and not in the application directory where you register an application initially. When my first tests failed I think my keys were marked invalid, one working solution is revoking the application access and renewing the keys, then test again and it works. Once it works, it works flawless.

After registering an app at Twitter and getting the keys, it is a nobrainer.

$status = 'some bogus text';

require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiCurl.php');	
require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiOAuth.php');
require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiTwitter.php');
$consumer_key = '';
$consumer_secret = '';
$oauth_token ='';
$oauth_token_secret = '';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$twitterObjUnAuth = new EpiTwitter($consumer_key, $consumer_secret); 
	   //$creds = $twitterObj->get('/account/verify_credentials.json');
$status = $twitterObj->post('/statuses/update.json', array('status' => $status));

Posted in sem, seo tips and tricks.

Leave a Reply

Your email address will not be published. Required fields are marked *