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" => 2, "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" => 2, "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 && user_access("access Blogger API")) { 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, w.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 echo lm("Distributed Authentication", array("mod" => "user", "op" => "help")) ?> 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 corresponding blogger-dev mailing list posts:
blogger.getPost()*To install the Blogger API module, enable the module in the site configuration - modules tab in the administration pages. Also make sure you have your permissions set correctly for accessing the Blogger API, the relevant settings can be found under the user management tab in the administration menu. Check the checkbox behind the line "access Blogger API" for the roles that are allowed to use the Blogger API. Make sure those roles have the right to "post content" as well.
Once the API is enabled you can download one of the above mentioned Blogger API clients and get blogging.
The Drupal page you need to call in order to connect using the Blogger API is http://server/xmlrpc.php where server is the URL of the site you want to post to. When posting to drupal.org, the account settings for i.e. w.bloggar would be: host: www.drupal.org (default = plant.blogger.com) and page: xmlrpc.php (default = /api/RPC2).
You can't use remote authentication when posting using a Blogger API enabled client, even when you could use that to authenticate on the site itself. You will have to use the site's local username, enter a password for that account, and then use that combination to post using the Blogger API client.
The original Drupal Blogger API implementation was authored by Julian Bond, and updated by the Drupal team.