Index: twitter.lib.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.lib.php,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 twitter.lib.php
--- twitter.lib.php	20 Oct 2010 15:18:10 -0000	1.1.2.6
+++ twitter.lib.php	6 Dec 2010 20:10:38 -0000
@@ -23,7 +23,7 @@ class Twitter {
   /**
    * @var $format API format to use: can be json or xml
    */
-  protected $format = 'json';
+  protected $format = 'xml';
 
   /**
    * @var $host The host to query against
@@ -259,9 +259,66 @@ class Twitter {
     switch ($format) {
       case 'json':
         return json_decode($response, TRUE);
+        break;
+      case 'xml':
+        return $this->_twitter_convert_xml_to_array($response);
+        break;
     }
   }
 
+  protected function _twitter_convert_xml_to_array($data) {
+    $results = array();
+    $xml = new SimpleXMLElement($data);
+    if (!empty($xml->name)) {
+      // Top-level user information.
+      $results[] = $this->_twitter_convert_user($xml);
+      return $results;
+    }
+    if (!empty($xml->user)) {
+      foreach($xml->user as $user) {
+        $results[] = $this->_twitter_convert_user($user);
+      }
+    }
+    elseif (!empty($xml->status)) {
+      foreach($xml->status as $status) {
+        $results[] = $this->_twitter_convert_status($status);
+      }
+    }
+    return $results;
+  }
+
+  protected function _twitter_convert_status($status) {
+    $result = (array)$status;
+    $result['twitter_id'] = $result['id'];
+    if (!empty($result['user']) && is_object($result['user'])) {
+      $result['account'] = $this->_twitter_convert_user($result['user']);
+      $result['user'] = $result['account'];
+      $result['screen_name'] = $result['account']['screen_name'];
+    }
+    else {
+      $result['screen_name'] = NULL;
+    }
+    $result['created_time'] = strtotime($result['created_at']);
+
+    // These come in as objects rather than strings IF they are empty, curiously
+    // enough. We want nulls, so we'll special case them.
+    foreach (array('in_reply_to_status_id', 'in_reply_to_user_id', 'in_reply_to_screen_name') as $key) {
+      if (is_object($result[$key])) {
+        $result[$key] = NULL;
+      }
+    }
+    return $result;
+  }
+
+  protected function _twitter_convert_user($user) {
+    $result = (array)$user;
+    $result['twitter_uid'] = $result['id'];
+    if (!empty($result['status']) && is_object($result['status'])) {
+      $result['status'] = $this->_twitter_convert_status($result['status']);
+    }
+    return $result;
+  }
+
   protected function create_url($path, $format = NULL) {
     if (is_null($format)) {
       $format = $this->format;
