--- twitter/twitter.lib.php	2010-02-13 23:11:45.000000000 -0500
+++ twitter/twitter.lib.php.new	2010-10-19 00:10:36.000000000 -0400
@@ -11,7 +32,9 @@
  * Exception handling class.
  */
 class TwitterException extends Exception {
-
+  public function __toString() {
+    return "exception '".__CLASS__ ."' with message '".$this->getMessage()."' in ".$this->getFile().":".$this->getLine()."\nStack trace:\n".$this->getTraceAsString();
+  }
 }
 
 /**
@@ -28,9 +51,14 @@ class Twitter {
   /**
    * @var $host The host to query against
    */
-  protected $host = 'twitter.com';
+  protected $host = 'api.twitter.com';
 
   /**
+   * @var $apiversion The version of the qpi to query against
+   */
+  protected $apiversion = '1';
+  
+  /**
    * @var $source the twitter api 'source'
    */
   protected $source = 'drupal';
@@ -186,10 +214,13 @@ class Twitter {
       }
     }
     catch (TwitterException $e) {
+      $exception = $e->__toString();
+      drupal_set_message(t('Caught @exception.', array('@exception' => $exception)),'error');
       return FALSE;
     }
 
     if (!$response) {
+    	drupal_set_message(t('Twitter returned no response.'),'warning');
       return FALSE;
     }
     
@@ -211,21 +242,26 @@ class Twitter {
    * Perform a request
    */
   protected function request($url, $params = array(), $method = 'GET', $use_auth = FALSE) {
+    $headers = array();
     $data = '';
     if (count($params) > 0) {
       if ($method == 'GET') {
-        $url .= '?'. http_build_query($params, '', '&');
+        $url .= '?'. http_build_query($params);
       }
       else {
-        $data = http_build_query($params, '', '&');
+        $dataarray=array();
+        foreach($params as $key => $value){
+            $dataarray[]=urlencode($key)."=".urlencode($value);
+        }
+        $data = implode('&', $dataarray);
+        $headers['Content-type'] = 'application/x-www-form-urlencoded';
       }
     }
 
-    $headers = array();
+
 
     if ($use_auth) {
       $headers['Authorization'] = 'Basic '. base64_encode($this->username .':'. $this->password);
-      $headers['Content-type'] = 'application/x-www-form-urlencoded';
     }
     
     $response = drupal_http_request($url, $headers, $method, $data);
@@ -253,15 +289,20 @@ class Twitter {
     }
   }
   
-  protected function create_url($path, $format = NULL) {
+  protected function create_url($path, $format = NULL, $includeversion = true) {
     if (is_null($format)) {
       $format = $this->format;
     }
     
-    $url =  'http://'. $this->host .'/'. $path;
+    if($includeversion)
+	    $url = 'http://'. $this->host .'/'. $this->apiversion. '/'. $path;
+	else
+		$url = 'http://'. $this->host .'/'. $path;
+		 
     if (!empty($format)) {
       $url .= '.'. $this->format;
     }
+    
     return $url;
   }
 }
@@ -286,7 +327,7 @@ class TwitterOAuth extends Twitter {
   }
 
   public function get_request_token() {
-    $url = $this->create_url('oauth/request_token', '');
+    $url = $this->create_url('oauth/request_token', '', false);
     try {
       $response = $this->auth_request($url);
     }
@@ -298,21 +339,21 @@ class TwitterOAuth extends Twitter {
   }
 
   public function get_authorize_url($token) {
-    $url = $this->create_url('oauth/authorize', '');
+    $url = $this->create_url('oauth/authorize', '', false);
     $url.= '?oauth_token=' . $token['oauth_token'];
   
     return $url;
   }
 
   public function get_authenticate_url($token) {
-    $url = $this->create_url('oauth/authenticate', '');
+    $url = $this->create_url('oauth/authenticate', '', false);
     $url.= '?oauth_token=' . $token['oauth_token'];
     
     return $url;
   }
 
   public function get_access_token() {
-    $url = $this->create_url('oauth/access_token', '');
+    $url = $this->create_url('oauth/access_token', '', false);
     try {
       $response = $this->auth_request($url);
     }
