array("function" => "bloggerapi_newPost"), "blogger.editPost" => array("function" => "bloggerapi_editPost"), "blogger.getUsersBlogs" => array("function" => "bloggerapi_getUsersBlogs"), "blogger.getUserInfo" => array("function" => "bloggerapi_getUserInfo"), "blogger.getTemplate" => array("function" => "bloggerapi_getTemplate"), "blogger.setTemplate" => array("function" => "bloggerapi_setTemplate"), "blogger.getPost" => array("function" => "bloggerapi_getPost"), "blogger.getRecentPosts" => array("function" => "bloggerapi_getRecentPosts"), "blogger.deletePost" => array("function" => "bloggerapi_deletePost") ); } /* ** The following functions map to the various Blogger method calls. ** All these functions subsequently use the blogger_driver function */ function bloggerapi_newPost($params) { global $user, $xmlrpcerruser; /* ** Call the driver function with appropriate method to return a node */ $node = node_validate(bloggerapi_driver("newPost", $params, $error), $error); if (!$node->error) { if (node_access("create", $node)) { throttle("node", variable_get("max_node_rate", 900)); $fields = array("uid" => $user->uid, "comment" => 1, "promote", "moderate", "status" => 1, "teaser", "title", "type" => $node->type, "body"); $nid = node_save($node, array_merge($fields, module_invoke($node->type, "save", "create", $node))); if ($nid) { watchdog("special", "$node->type: added '$node->title', via Blogger API"); return new xmlrpcresp(new xmlrpcval("$nid", "string")); } else { $error = bloggerapi_error("Error posting node"); return $error->error_resp; } } } return $node->error_resp; } function bloggerapi_editPost($params) { global $user, $xmlrpcerruser; $node = node_validate(bloggerapi_driver("editPost", $params, $error), $error); if (!$node->error) { $filter = array("nid" => $node->nid, "uid" => $user->uid, "comment" => 1, "promote", "moderate", "status" => 1, "teaser", "title", "type" => $node->type, "body"); $nid = node_save($node, array_merge($filter, module_invoke($node->type, "save", "update", $node))); if ($nid) { watchdog("special", "$node->type: updated '$node->title', via Blogger API"); return new xmlrpcresp(new xmlrpcval($nid, "string")); } else { # $error = bloggerapi_error("Error updating node: $node->nid"); return $node->error_resp; } } return $node->error_resp; } function bloggerapi_getUsersBlogs($params) { $resp = bloggerapi_driver("getUsersBlogs", $params); if (!$resp->error) { return new xmlrpcresp($resp); } else { return $resp->error_resp; } } function bloggerapi_getUserInfo($params) { $resp = bloggerapi_driver("getUserInfo", $params); if (!$resp->error) { return new xmlrpcresp($resp); } else { return $resp->error_resp; } } function bloggerapi_getTemplate($params) { $error = bloggerapi_error(t("Get Template is not relevant for Drupal")); return $error->error_resp; } function bloggerapi_setTemplate($params) { $error = bloggerapi_error(t("Set Template is not relevant for Drupal")); return $error->error_resp; } function bloggerapi_getPost($params) { $resp = bloggerapi_driver("getPost", $params); if (!$resp->error) { return new xmlrpcresp($resp); } else { return $resp->error_resp; } } function bloggerapi_getRecentPosts($params) { $resp = bloggerapi_driver("getRecentPosts", $params); if (!$resp->error) { return new xmlrpcresp($resp); } else { return $resp->error_resp; } } function bloggerapi_deletePost($params) { $resp = bloggerapi_driver("deletePost", $params); if (!$resp->error) { return new xmlrpcresp($resp); } else { return $resp->error_resp; } } function bloggerapi_driver($method, $params = 0, $error = 0) { global $user, $xmlrpcusererr; /* ** Convert parameters to an array */ $cparams = bloggerapi_convert($params); /* ** Validate the user, the postion in the array for username and password ** are not always the same. */ if ($method == "getUsersBlogs" || $method == "getUserInfo") { $user = bloggerapi_validate_user($cparams[1], $cparams[2]); } else { $user = bloggerapi_validate_user($cparams[2], $cparams[3]); } if ($user->uid && variable_get("bloggerapi", 0) && user_access("access bloggerapi")) { if (user_access("post content")) { /* ** Check for title tags, if not generate one. */ if (eregi("
Blogger, the well-known public weblog service, provides an application programing interface (API) to allow remote procedure calls (RPC) to the Blogger service. Drupal supports this Blogger API, which means that many remote clients (e.g. Radio, TextRouter, Blogbuddy, Bloggar,PerlyBlog), may post to Drupal. These clients provide a bevy of interesting capabilities like offline composing, spellcheck, and WYSIWYG editing; many folks prefer to blog with a client application over typical web forms. By supporting the Blogger API, Drupal grows grander than a web site engine, it's a content accepting machine™.
The Blogger RPC API uses the XML-RPC protocol for communicating with the outside world. XML-RPC, originally developed by Dave Winer of UserLand Software, is a simple XML-based RPC specification ideally suited to the web. Drupal also uses XML-RPC for several other tasks (e.g. notifiying weblogs.com of blog updates and making/accepting Distributed Authentication requests)
A word of warning on the Blogger API: It is unofficial. It exists because Blogger is one of the most popular services and also they were first to implement an XML-RPC interface to their service. It is certainly not the best implementation of a distributed weblog API. For a promising candidate, see Wasabii.
Drupal's support for the Blogger API is quite complete. Each method with an asterisk below has been implemented in Drupal.
blogger.newPost()*Drupal also supports the following methods. These methods were added after the those listed above and are not documented on the Blogger API website. Each method is linked to its corrosponding blogger-dev mailing list posts:
blogger.getPost()*The Blogger API exists as a Drupal module (bloggerapi.module) which can be downloaded from cvs-contrib. For instructions on how to access the CVS repositories please see this document. Once downloaded the module simple needs to be copied to you Drupal modules directory. Under the "Settings and Filters" tab in the administration menue look for the Blogger API entry. There are two settings for the module either enabled or disabled. Also make sure you have you permission set correctly for accessing the Blogger API, the relevent setings can be found under the "User Management" tab in the administration menu.
Once the API is enabled you can download one of the above mentioned Blogger API clients and get blogging...
The original Drupal Blogger API implementation was authored by Julian Bond, and updated by the Drupal Development Team.