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.

  1.  
  2. $status = 'some bogus text';
  3.  
  4. require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiCurl.php');
  5. require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiOAuth.php');
  6. require_once(WP_PLUGIN_DIR . '/myplugin/epitwitter/EpiTwitter.php');
  7. $consumer_key = '';
  8. $consumer_secret = '';
  9. $oauth_token ='';
  10. $oauth_token_secret = '';
  11. $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
  12. $twitterObjUnAuth = new EpiTwitter($consumer_key, $consumer_secret);
  13. $twitterObjUnAuth->getAuthenticateUrl();
  14.     //$creds = $twitterObj->get('/account/verify_credentials.json');
  15. $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 *