wordpress to twitter plugin error

Scenario:

I upgrade one of my wordpress plugin “WP to Twitter” to latest version (Version 2.2.0) for the OAuth and found that it doesn’t work with my hosting plan (hostgator).
When I click on the “Connect to Twitter” and there is a fatal error “Fatal error: Class ‘OAuthSignatureMethod_HMAC_SHA1′ not found.
After performing some debugging and found that it is due to OAuth enabled in my hostgator PHP.

In hostgator, they are using PHP 5.2.14 with OAuth enabled. This is the main reason causing the problem.
Inside the PHP OAuth, it contain of a set of classes (OAuthException is one of them) and “WP to Twitter” plugin is using this class to perform some checking and causing the problem.

Solution:

Here is the modification that I done for my wordpress plugin.

<?php
// vim: foldmethod=marker
 
// remove the checking on class OAuthException and add in for OAuthConsumer
// if (!class_exists('OAuthException')) {
if (!class_exists('OAuthConsumer')) {
 
// Comment the OAuthException class
/* Generic exception class
 */
//class OAuthException extends Exception {
  // pass
//}
 
class OAuthConsumer {
  public $key;
  public $secret;
 
  function __construct($key, $secret, $callback_url=NULL) {
    $this->key = $key;
    $this->secret = $secret;
    $this->callback_url = $callback_url;
  }
 
  function __toString() {
    return "OAuthConsumer[key=$this->key,secret=$this->secret]";
  }
}
 
//more codes below

6 Comments to “wordpress to twitter plugin error”

  1. Dont 4 September 2010 at 6:46 pm #

    I was looking for exactly this, thanks for the help. A short addendum however: you also need to comment out the last right curly bracket at the end of the file (with version 2.2.1 at least).

  2. Eric 8 April 2011 at 6:45 am #

    Hi, Thanks very much it just resolved the same issue today !

  3. Rob 10 October 2011 at 10:10 pm #

    Thank you very much for the solution to get rid of this horrible error!

    • h2Guru 11 October 2011 at 12:02 am #

      You are welcome!!!

  4. vinnie 30 January 2012 at 11:04 pm #

    dude…. thank you so freaking much!!!

    i’ve been reading every single line of the “twitter tools” plugin for wordpress.
    i couldn’t find the bloody problem….

    your solution just fixed it all!
    i could kiss you!

    thanks for posting this for everybody to read.

  5. Chuck Spidell 27 June 2012 at 8:49 am #

    Thanks. Works great.


Leave a Reply