RSS
people

wp to twitter 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

5 Responses to “wp to twitter error”

  1. Dont said:
    September 4th, 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).

    1. Eric said:
      April 8th, 2011 at 6:45 am

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

      1. Rob said:
        October 10th, 2011 at 10:10 pm

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

        1. h2Guru said:
          October 11th, 2011 at 12:02 am

          You are welcome!!!

          1. vinnie said:
            January 30th, 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.

            Leave a Reply