The Blog API module, included in Drupal 5 & 6 and available via the separate BlogAPI contrib module for Drupal 7, enables a post to be published to a site via external GUI applications. Many users prefer to use external tools to improve legibility and posting responses in a customized way. The Blog API module provides users the freedom to use the blogging tools they want but still have the blogging server of choice.

When this module is enabled and configured, you can use a variety of programs to create and publish posts from your desktop. Blog API module supports several XML-RPC based blogging APIs such as the Blogger API (outdated) (new Blogger Data API, MetaWeblog API, and most of the Movable Type API.

For more information on using software with the Blog API, see the Creating new content section of the End user Guide.

This module also allows site administrators to configure which content types can be posted via the external applications. So, for instance, users can post forum topics as well as blog posts. Where supported, the external applications will display each content type as a separate "blog".

To configure your blogging client for use with your Drupal site enter http://example.com/xmlrpc.php as the API URL for your blog.

You can:

  • view the XML-RPC page.
  • Administer > Settings > Blogapi.

Comments

nonsie’s picture

1. Enable and configure Blog API (choose content types allowed)
2. On Flickr on Your account->Blogs->Add a blog choose MetaWeblogAPI Enabled Blog from blog type drop down box
3. On the next screen enter http://your_site/xmlrpc.php as the API URL, make sure to add username and password for the user you'd like to post as, click on Next
4. On the next screen you're asked to confirm details, if everything is correct click on All done

To test that everything has been set up correctly you can use "test post" feature on Your account->Blogs page. This will post a sample to your site if everything is configured properly.

BenStallings’s picture

Those wishing to set up the Blog API for use with Windows Live Writer may experience some weird compatibility issues. At any rate, I did. Your mileage may vary.

First, WLW only imported the first 23 categories that are available to bloggers on my site, and it truncated some of their names, resulting in categories like "Batter" and "Interne", and it didn't keep them grouped in their vocabularies. The upshot being that I have to tell my bloggers not to use categories when posting with WLW, but instead to edit the posts in Drupal and add the categories that way.

Second, WLW's "split post" feature, which is available when using the Movable Type API but not with the Metaweblog API, does not produce the <!--break--> tags that Drupal expects. Instead it produces <!--pagebreak--> sometimes and <!--extended--> other times, despite the fact that before posting, the HTML source within WLW shows <!--more-->. Supporting all of these possible page-breaking tags in Drupal would require hacking the core.

Suggestions welcome!

keathmilligan’s picture

Here is a very simple module that will solve this problem:

1) Create a directory under modules called "blogapi_break_converter".

2) Create a file in this directory named "blogapi_break_converter.info" that contains:

; $Id: $
name = Blog API Break Converter
description = Converts <!--extended--> tag to <!--break-->
version = 6.x-1.0-dev
core = 6.x
dependencies[] = blogapi

3) Create another file called "blogapi_break_converter.module" that contains the following code:

// $Id: $

/**
 * @file
 * Converts <!--extended--> to <!--break-->
 */

/**
 * Implements hook_nodeapi()
 */
function blogapi_break_converter_nodeapi(&$node, $op) {
  if ($op == "blogapi new" || $op == "blogapi edit") {
    $node->body=str_replace('<!--extended-->','<!--break-->',$node->body);
  }
}

Now just enable the module in the modules administration page and you should be good to go. I use the MoveableType APIs in WLW and I don't get the "<!--pagebreak-->" variant, but the code above could easily be modified to handle that as well.

billspeers’s picture

wlw works with blogapi as detailed here:
http://billspeers.com/?q=node/297

MarcoF’s picture

Hello,

my real, general questions (the one below is just an example) is: which tools/scripts do you use to write, read and edit remotely, via XMLRPC / BlogAPI, nodes created with CCK, that is nodes which have (many more) custom fields than the default ones in the blogger or metaweblog specs? Do you have working code to share or study?

I've made a bit of searching and found reports that mtsend.py could be used with Drupal, as well as the drupal.org page "Example: XML-RPC CCK Field XML Format" on the same topic.

None of them are complete answers, however, in the sense that there is no complete info on how to write or read all fields of a drupal CCK node with that syntax using mtsend.py or any other blogger/metaweblog API client.

As an example, I have found that using the Perl XMLRPC::Lite module you can get only a few, default fields of a custom node you created with the CCK module. In other words, if I run this code (from the XMLRPC::Lite documentation):

my $msgresult = XMLRPC::Lite
         -> proxy($proxyurl)
    -> call('metaWeblog.getRecentPosts', $blogid, $username, $password,1)
         -> result;

print Dumper ($msgresult);

on a website I work on, it works, but only prints these fields and their values:

            'link',
            'permaLink',
            'userid',
            'mt_allow_comments' ,
            'content' => 'SAME AS TITLE BELOW, INSTEAD OF THE ACTUAL CONTENT OF THAT NODE,
            'description' => '',
            'mt_convert_breaks' => '0',
            'postid' => '1',
            'title' => 'ACTUAL TITLE OF THE NODE',
            'dateCreated' => '20090227T21:57:08'

but that node I'm trying to see belongs to a CCK content type which also has other fields (Location, Speaker and others, plus taxonomies).

So, the question is, how would I read those other fields? A and how would I WRITE them, that is how would I trick the XMLRPC::Lite module into sending them to Drupal, if it only knows those basic fields? This seems a limitation of the particular Perl module I've used, but...

In general, is it possible to read/write any field of any content type of a Drupal CCK content type? The answer seems yes, but is there any more documentation but those two links I give above?

Even more important, is there any existing XMLRPC library or client in Perl, Python or other Linux friendly scripting languages which already supports, as is, reading, writing and editing of all fields of a Drupal node via XMLRPC?

awahan’s picture

You can do this with the Services module. I don't think the Blog API can return the CCK fields. The Services module does.

Example code with the Perl XMLRPC::Lite module:

my $xmlrpc = XMLRPC::Lite -> proxy($proxyurl);

my $connect = $xmlrpc -> call('system.connect') -> result;
print "System.connect: ", Dumper($connect);
my $sessid = $connect->{sessid};

my $login = $xmlrpc -> call('user.login', $sessid, $username, $password) -> result;
print "User.login: ", Dumper($login);
$sessid = $login->{sessid};

my $nid = 2; # the node ID
my $node = $xmlrpc -> call('node.get', $sessid, $nid, []);
my $msgresult = $node -> result;
print "Node.get: ", Dumper($msgresult);

You can also add a node with CCK fields:

my $newnode = {
	'type' => 'job',
	'title' => 'Teaching Aid',
	'field_department' => [ { 'value' => 'Sciences' } ],
	'body' => '<p>Epic University is currently looking to fill the position of Teaching Aid. This position will have the following duties:<br/>
<br/>
- Maintaining contact with first-year students<br/>
- Correct exams</p>',
	'field_salary' => [ { 'value' => '10000' } ],
	'field_contact' => [ { 'uid' => '3' } ]
	};
my $savenode = $xmlrpc -> call('node.save', $sessid, $newnode);
my $newnoderesult = $savenode -> result;
mattman’s picture

After having had some issues with connecting to a Drupal blog via Blog API, using ecto, I decided to do something about it.

I made this video about Drupal's Blog API. Maybe it will help some other people get their blogging client connected.

spomerg’s picture

Thanks for your video, it was very helpful. I have not been able to get the "Drupal pipe" working with Pixelpipe. I wanted to rule out my Drupal config/setup as the culprit so I downloaded Qumana for my iMac and was able to post just fine. My settings for my Drupal pipe are as follows:

Server: http://www.mydrupalsite.com/xmlrpc.php
Display name: Me
Default for new uploads: Send
Routing tag(s): blank (but also tried adding "drupal")
Post items: individually immediately

And of course I have my Drupal username and password in there too. My Drupal log shows I connected to xmlrpc.php, but the Pixelpipe error message says:

Drupal(Blog): failed due to You must upload an image.. Will be re-tried at 2009-05-20 14:54:41.0

Well, I DID upload an image to Pixelpipe. But apparently Pixelpipe cannot upload it to my drupal site. ;)

Has anyone else tried with Pixelpipe?

- Gavin

aliball68’s picture

Hi Gavin,

I have also tried uploading an image with pixelpipe - the subject and content go through just fine but the image does not appear anywhere. I have exactly the same settings as you and have tried the web based version and also the one for the Android and neither seem to work.

Would love to hear back from you if you managed to sort it out as I haven't.

Ali

kadoudal’s picture

did you solved it ? I think it's related to HTML filtering..
I had the same issue... I edited the post then with no HTL filering and I got the image ...

dobeerman’s picture

I have a problem with image publication with BlogAPI clients.
WLW & ScribeFire FF addon...
ScribeFire returns error about file size more than 0.

Any idea?

sparkalow’s picture

I had the file size more than 0 error. Gave authenticated users permission to use the blog api and it resolved it.

jakemonO’s picture

I'm not sure of the internal working of the xml-rpc connection, but when I connect to my "custom" blog (not a standard Drupal user's blog) Windows Live writer seems to get the impression that the blog's homepage is http://mysite/blog/1 when it is in fact a custom view. IMHO, there should be a way to override this function from the blog API admin page to specify what this home url should be.

lameei’s picture

Published content gets the path of one of old contents so when you click the link you will be redirected to the old content not the newly published one. I have path auto enabled.

MatWho’s picture

If you are trying to post via the Blog API (calling xmlrpc.php) and you get things like this:

pThis is great you can open a terminal from the Mac finder:/p

Then you need to downgrade your libXML to version 2.6.

For a fix that does not require this downgrade, look at this article : http://www.janganan.com/2009/02/how-to-handle-libxml-bug-in-drupal.html

To help the code required is here, for you to copy/paste:

$message=str_replace("<","<",$message);
$message=str_replace(">",">",$message);
$message=str_replace("&","&",$message);
dalinian’s picture

The Open Office Weblog Extension fails to register forum terms to forum posts. So you can post a forum content type, but you cannot associate it with any specific forum (term name), even though the OO gui sees the forum term name and allows you to select it.

peti2006@googlemail.com’s picture

Hi,

I'm using Drupal 6.12.
I can post content and upload images. But, I got users permission problem.
It's working for admin but all other authenticated users can only see the content but not the uploaded images.
Does anyone know about this problem?
Thanks in advance.

onyxnz’s picture

Yep, just came across it...
it's the Input format. It needs to be able to use the <img> tag, which by default Filtered HTML cannot. So either set everyone to use Full HTML (a bit dangerous) or add <img> to the list of allowed tags here: /admin/settings/filters/1/configure

berend’s picture

How is it that Drupals XML-RPC supports the new Blogger Data API when this is not an XML-RPC proto?
Can someone explain this?

The link supplied here leads to information on what looks like a RESTful API, so I am forced to conclude the assertion is in error..
Or perhaps it only is with the Blog module enabled.

jdleonard’s picture

billspeers’s picture

you inspired me to write one for drupal 7 and blog api:
http://billspeers.com/?q=node/297