Publishing to drupal with org2blog

org2blog is an org-mode plugin which allows to publish an org file to a wordpress blog. The connection between org-mode and wordpress is achived through an xmlrpc call using the metaweblog api.

My blog is powered by drupal which supports xmlrpc calls and the metaweblog api. The setup although was not straightforward. In this post I'm going to show the steps that I followed in order to make it work.


First of all in order to enable xmlrpc calls to our drupal blog we need to install the blog api:

root@mazinga:/var/www# drush dl blogapi
Project blogapi (7.x-2.0-rc1) downloaded to /var/www/sites/all/modules/blogapi.                                                                     [success]
Project blogapi contains 4 modules: blogapi_movabletype, blogapi_blogger, blogapi_metaweblog, blogapi.

root@mazinga:/var/www# drush en blogapi
The following projects have unmet dependencies:
blogapi requires services
Would you like to download them? (y/n): y
Project services (7.x-3.19) downloaded to /var/www/sites/all/modules/services. [success]
Project services contains 4 modules: services_oauth, rest_server, xmlrpc_server, services.
The following projects have unmet dependencies:
blogapi requires ctools
Would you like to download them? (y/n): y
Project ctools (7.x-1.12) downloaded to /var/www/sites/all/modules/ctools.     [success]
Project ctools contains 10 modules: ctools_ajax_sample, page_manager, views_content, bulk_export, 
ctools_plugin_example, ctools_custom_content, ctools_access_ruleset, term_depth, stylizer, ctools.
failed to open stream: No such file or                                         [warning]
The following extensions will be enabled: blogapi, ctools, services
Do you really want to continue? (y/n): y
blogapi was enabled successfully.                                              [ok]
ctools was enabled successfully.                                               [ok]
services was enabled successfully.                                             [ok]

Then we need to enable some stuff, so we have to log in as user/1 on our site, go to modules section and check:

  • BlogAPI
  • MetaWeblog Provider for BlogAPI
  • Services
  • XMLRPC Server

The services module has to be configured so go to Modules/services/Configure and select Edit Resources. Here we can choose which methods we would like to enable. I selected all the methods.

In Configuration/Web services/BlogAPI enable MetaWeblog as the default provider for xmlrpc APIs.

Configuration in drupal is almost done, the last step is to write down the endpoint of the xmlrpc service. This information is in: Modules/services/Configure/Modify/Path to endpoint


We need to install org2blog and enable it, then we define the handle to our blog:

(require 'org2blog-autoloads)
;;; org2blog
(setq org2blog/wp-blog-alist
         :url ""
         :default-categories ("linux")
         :tags-as-categories nil
         :id "blog"
         :username "XXXX"
         :password "YYYY" )))

The relevant parts here are:

  • url is composed by site_url plus xmlrpc path end point
  • id is the id our blog, we must specify this option otherwise org2blog defaults to id 1 which is not present in drupal

org2blog uses some wordpress apis which are not compatible with drupal: if we try to connect to our blog we get an error. We have to redefine two functions to bypass those errors:

(eval-after-load "metaweblog"
  '(defun wp-get-tags (blog-xmlrpc user-name password blog-id)
     "Retrieves list of tags from the weblog system. Uses wp.getTags"
     (xml-rpc-method-call blog-xmlrpc

(eval-after-load "metaweblog"
  '(defun wp-get-pagelist (blog-xmlrpc user-name password blog-id)
     (xml-rpc-method-call blog-xmlrpc

That should be all that is needed.

What's next

I have to understand how to upload images (I receive a SQL error when I publish a post with an image inside) and how to attach categories to a post, but I'm pretty satisfied with the actual integration: this post for example is published using org2blog!



Aggiungi un commento