- Committed (a slightly modified version of) PiAir's Blogger API documentation
patch.4.1.x
parent
15a9b6c503
commit
5c66243d81
|
@ -117,7 +117,8 @@ function bloggerapi_getRecentPosts($params) {
|
|||
|
||||
if (!$resp->error) {
|
||||
return new xmlrpcresp($resp);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $resp->error_resp;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +128,8 @@ function bloggerapi_deletePost($params) {
|
|||
|
||||
if (!$resp->error) {
|
||||
return new xmlrpcresp($resp);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $resp->error_resp;
|
||||
}
|
||||
}
|
||||
|
@ -148,11 +150,12 @@ function bloggerapi_driver($method, $params = 0, $error = 0) {
|
|||
|
||||
if ($method == "getUsersBlogs" || $method == "getUserInfo") {
|
||||
$user = bloggerapi_validate_user($cparams[1], $cparams[2]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$user = bloggerapi_validate_user($cparams[2], $cparams[3]);
|
||||
}
|
||||
|
||||
if ($user->uid && user_access("access bloggerapi")) {
|
||||
if ($user->uid && user_access("access Blogger API")) {
|
||||
if (user_access("post content")) {
|
||||
|
||||
/*
|
||||
|
@ -162,7 +165,8 @@ function bloggerapi_driver($method, $params = 0, $error = 0) {
|
|||
if (eregi("<title>(.*)</title>", $cparams[4], $title)) {
|
||||
$title = strip_tags($title[0]);
|
||||
$cparams[4] = ereg_replace("<title>.*</title>", "", $cparams[4]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$title = bloggerapi_title($cparams[4]);
|
||||
}
|
||||
|
||||
|
@ -180,7 +184,8 @@ function bloggerapi_driver($method, $params = 0, $error = 0) {
|
|||
$node = node_load(array("nid" => $cparams[1]));
|
||||
if ($node->uid == $user->uid) {
|
||||
return array("nid" => $cparams[1], "type" => "blog", "title" => $title, "teaser" => $teaser, "body" => $cparams[4], "status" => 1, "moderate" => 0, "comment" => 2, "promote" => 0, "revision" => 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error updating node");
|
||||
}
|
||||
break;
|
||||
|
@ -226,7 +231,8 @@ function bloggerapi_user_blogs() {
|
|||
"blogName" => new xmlrpcval($user->name . "'s blog at ". variable_get("site_name", "drupal"))
|
||||
),"struct");
|
||||
return new xmlrpcval(array($struct), "array");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error retrieving user blogs");
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +248,8 @@ function bloggerapi_user_info() {
|
|||
"lastname" => new xmlrpcval(substr($user->name, strrpos($user->name," ")+1), "string"),
|
||||
"firstname" => new xmlrpcval(substr($user->name, 0, strrpos($user->name," ")), "string"),
|
||||
), "struct");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error retrieving user information");
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +265,8 @@ function bloggerapi_node_load($nid) {
|
|||
"content" => new xmlrpcval($body,"string"),
|
||||
"postid" => new xmlrpcval($blog->nid,"string")
|
||||
), "struct");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error retrieving blogid: $nid");
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +286,8 @@ function bloggerapi_node_recent($num) {
|
|||
), "struct");
|
||||
}
|
||||
return new xmlrpcval($blogs, "array");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error retrieving recent blogs");
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +310,8 @@ function bloggerapi_node_delete($nid) {
|
|||
$message = "Node: $node->nid, was deleted";
|
||||
return new xmlrpcval($message, "string");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return bloggerapi_error("Error deleting node: $nid");
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +341,8 @@ function bloggerapi_validate_user($username, $password) {
|
|||
if ($username && $password) {
|
||||
$user = user_load(array("name" => $username, "pass" => $password, "status" => 1));
|
||||
return $user;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +372,7 @@ function bloggerapi_watchdog() {
|
|||
}
|
||||
|
||||
function bloggerapi_perm() {
|
||||
return array("access bloggerapi");
|
||||
return array("access Blogger API");
|
||||
}
|
||||
|
||||
function bloggerapi_system($field){
|
||||
|
@ -373,14 +384,12 @@ function bloggerapi_help() {
|
|||
?>
|
||||
<h3>Introduction</h3>
|
||||
|
||||
<p><a href="http://www.blogger.com">Blogger</a>, 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 <a href="http://plant.blogger.com/api/index.html">Blogger API</a>, which means that many remote clients (e.g. <a href="radio.userland.com">Radio</a>, <a href="http://simon.kittle.info/textrouter">TextRouter</a>, <a href="http://blogbuddy.sourceforge.net/">Blogbuddy</a>, <a href="http://www.bloggar.cjb.net/">Bloggar</a>,<a href="http://www.tswoam.co.uk/index.php?n_go=16">PerlyBlog</a>), 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 <i>content accepting machine</i>™.
|
||||
<p><a href="http://www.blogger.com">Blogger</a>, 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 <a href="http://plant.blogger.com/api/index.html">Blogger API</a>, which means that many remote clients (e.g. <a href="radio.userland.com">Radio</a>, <a href="http://simon.kittle.info/textrouter">TextRouter</a>, <a href="http://blogbuddy.sourceforge.net/">Blogbuddy</a>, <a href="http://www.wbloggar.com/">w.bloggar</a>, <a href="http://www.tswoam.co.uk/index.php?n_go=16">PerlyBlog</a>), 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 <i>content accepting machine</i>™.
|
||||
<p>The <a href="http://plant.blogger.com/api/index.html">Blogger RPC API</a> uses the <a href="http://www.xmlrpc.com">XML-RPC</a> protocol for communicating with the outside world. XML-RPC, originally developed by Dave Winer of <a href="http://www.userland.com">UserLand Software</a>, is a simple XML-based RPC specification ideally suited to the web. Drupal also uses XML-RPC for several other tasks (e.g. notifiying <a href="http://www.weblogs.com">weblogs.com</a> of blog updates and making/accepting <? echo lm("Distributed Authentication", array("mod" => "user", "op" => "help")) ?> requests)</p>
|
||||
|
||||
<h3>Blogger API implementation</h3>
|
||||
|
||||
<p><small>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 <a href="http://www.wasabii.org"> Wasabii</a>.</small></p>
|
||||
<p>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 <a href="http://www.wasabii.org">Wasabii</a>.</p>
|
||||
|
||||
<p>Drupal's support for the Blogger API is quite complete. Each method with an asterisk below has been implemented in Drupal.</p>
|
||||
|
||||
|
@ -399,8 +408,13 @@ allow remote procedure calls (RPC) to the Blogger service. Drupal supports this
|
|||
|
||||
<h3>Installation and usage</h3>
|
||||
|
||||
<p>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.</p>
|
||||
<p>Once the API is enabled you can download one of the above mentioned Blogger API clients and get blogging ...</p>
|
||||
<p>To install the Blogger API module, enable the module in the <i>site configuration - modules</i> 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 <i>user management</i> 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.</p>
|
||||
<p>Once the API is enabled you can download one of the above mentioned Blogger API clients and get blogging.</p>
|
||||
|
||||
<h3>Setup of the client</h3>
|
||||
|
||||
<p>The Drupal page you need to call in order to connect using the Blogger API is <i>http://server/xmlrpc.php</i> where <i>server</i> is the URL of the site you want to post to. When posting to drupal.org, the account settings for i.e. <a href="http://www.wbloggar.com/">w.bloggar</a> would be: host: www.drupal.org (default = plant.blogger.com) and page: xmlrpc.php (default = /api/RPC2).</p>
|
||||
<p>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.</p>
|
||||
|
||||
<h3>Notes and limitations</h3>
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue