Index: pingfm/pingfm.module
===================================================================
--- pingfm/pingfm.module	(revision 4394)
+++ pingfm/pingfm.module	(working copy)
@@ -149,7 +149,30 @@
         '!user' => $node->name,
       );
       $result = pingfm_post(t($node->pingfm['format'], $replacements), $node->pingfm['method'], $node->title, user_load(array('uid' => $node->uid)));
-      drupal_set_message($result ? t('Successfully posted to Ping.fm') : t('Failed posting to Ping.fm'), $result ? 'status' : 'warning');
+      if ($result->status == 1) {
+        drupal_set_message(t('Successfully posted to Ping.fm'), 'status');
+      }
+      else {
+	$msg = $result->message;
+        //$msg = '$result = array(';
+        //$first = TRUE;
+	//if ($result['status']) {
+	//  $msg .= '["status"] => "' . $result['status'] . '"';
+	//  $first = FALSE;
+	//}
+        //foreach ($result as $k => $v) {
+        //  if ($first) {
+        //    $first = FALSE;
+        //  }
+        //  else {
+        //    $msg .= ', ';
+        //  }
+        //  if (is_bool($v)) $v = $v ? 'TRUE' : 'FALSE';
+        //  $msg .= '"' . $k . '" => "' . addslashes($v) . '"';
+        //}
+        //$msg .= ');';
+        drupal_set_message(t('Failed posting to Ping.fm (@xml)', array('@xml' => $msg)), 'warning');
+      }
     }
     break;
   }
Index: pingfm/phpingfm/PHPingFM.php
===================================================================
--- pingfm/phpingfm/PHPingFM.php	(revision 4161)
+++ pingfm/phpingfm/PHPingFM.php	(working copy)
@@ -30,6 +30,11 @@
   protected $user_app_key;
 
   /**
+   * The Pingfm XML result.
+   */
+  protected $result;
+
+  /**
    * Initializes the API key, User's APP key, and cURL handler.
    * 
    * @param $api_key
@@ -44,6 +49,7 @@
    * @see setUserAppKey
    */
   function __construct($api_key, $user_app_key = NULL, $debug = FALSE) {
+    $this->result = (object)array('status' => FALSE, 'body' => 'Never called Ping.fm.');
     $this->api_key = $api_key;
     // Since it is optional, we need to check if it's set.
     if ($user_app_key) {
@@ -86,14 +92,15 @@
    *   The fields to pass in over POST.  The user's app key and the API key are
    *   automatically added.
    * @return
-   *   An array with two elements – status, which is a boolean which indicates
-   *   whether the operation succeeded or not, and response, which is the XML of the
-   *   response, in SimpleXML format.
+   *   An object with the response. The important fields are status, when set to 1
+   *   the transaction succeeded, otherwise it failed. The other parameter is message
+   *   that is set to the error message when status is not 1.
    */
   protected function callMethod($service, $fields = array()) {
     // Make sure we have an app key.
     if (!isset($this->user_app_key)) {
-      return array('status' => FALSE);
+      $this->result = (object)array('status' => FALSE, 'body' => 'User application key is missing.');
+      return $this->result;
     }
     // Setup the cURL options.
     curl_setopt_array($this->ch, array(
@@ -101,10 +108,16 @@
       CURLOPT_URL => 'http://api.ping.fm/v1/'. $service,
     ));
     // Load the SimpleXML.
-    $xml = simplexml_load_string(curl_exec($this->ch));
-    // Check the status.
-    $status = ($xml['status'] == 'OK');
-    return array('status' => $status, 'response' => $xml);
+    $xml = curl_exec($this->ch);
+    if ($xml) {
+      $this->result = simplexml_load_string($xml);
+      $this->result->xml = $xml;
+      $this->result->status = $this->result['status'] == 'OK';
+    }
+    else {
+      $this->result = (object)array('xml' => $xml);
+    }
+    return $this->result;
   }
 
   /**
@@ -150,8 +163,7 @@
    *   A boolean of whether the app key is correct.
    */
   function validate() {
-    $validates = $this->callMethod('user.validate');
-    return $validates['status'];
+    return $this->callMethod('user.validate');
   }
 
   /**
@@ -164,12 +176,12 @@
   function services() {
     $services = $this->callMethod('user.services');
     // If it didn't succeed, don't proceed.
-    if (!$services['status']) {
+    if ($services->status != 1) {
       return FALSE;
     }
     $service_array = array();
     // Iterate through all services.
-    foreach ($services['response']->services->service as $service) {
+    foreach ($services->services->service as $service) {
       $service_array[(string)$service['id']] = array(
         'name' => (string)$service['name'],
         'methods' => explode(',', (string)$service->methods),
@@ -187,7 +199,7 @@
   function triggers() {
     $triggers = $this->callMethod('user.triggers');
     // If it didn't succeed, don't proceed.
-    if (!$triggers['status']) {
+    if ($triggers->status != 1) {
       return FALSE;
     }
     $trigger_array = array();
@@ -221,12 +233,12 @@
   function latest($limit = 25, $order = "DESC") {
     $messages = $this->callMethod('user.latest', array('limit' => $limit, 'order' => $order));
     // If it didn't succeed, don't proceed.
-    if (!$messages['status']) {
+    if ($messages->status != 1) {
       return FALSE;
     }
     $messages_array = array();
     // Go through each message, parsing them
-    foreach ($messages['response']->messages->message as $message) {
+    foreach ($messages->messages->message as $message) {
       $messages_array[(string)$message['id']] = $this->parseMessage($message);
     }
     return $messages_array;
@@ -255,12 +267,11 @@
     if ($services) {
       $fields['service'] = implode(',', $services);
     }
-    $response = $this->callMethod('user.post', $fields);
-    return $response['status'];
+    return $this->callMethod('user.post', $fields);
   }
 
   /**
-   * Public API function: user.tpost: posts a message to the user’s Ping.fm
+   * Public API function: user.tpost: posts a message to the user's Ping.fm
    * services using one of their custom triggers.
    * 
    * @param $trigger
@@ -276,7 +287,13 @@
     if ($title) {
       $fields['title'] = $title;
     }
-    $response = $this->callMethod('user.tpost', $fields);
-    return $response['status'];
+    return $this->callMethod('user.tpost', $fields);
   }
+
+  /**
+   * Return the last result object.
+   */
+  function last_result() {
+    return $this->result;
+  }
 }
