Posting to Drupal through XMPRPC / BlogAPI

Tags: 

When I migrated my blog from Wordpress to Drupal one key thing I still wanted to do was be able to use ecto to post messages from my laptop rather than through the web interface - it can be just easier at times. Thankfully Drupal has a plugin/module built in which does this for you, the BlogAPI module. So I activate the module then try to connect using ecto only to be greeted with the lovely message:

The response from the server did not contain valid data.

This was frustrating, it should just work, right? Thankfully ecto has a console feature which displays all communications with the server, and I was able to see it submit:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>blogger.getUsersBlogs</methodName>
<params>
        <param>
                <value><string>ignore</string></value>
        </param>
        <param>
                <value><string>Damien</string></value>
        </param>
        <param>
                <value><string>*****************</string></value>
        </param>
</params>
</methodCall>

This is a normal Blogger API call to find out what blogs a given user (me) has permission to write on at a given blog installation, and should have returned some valid data. Here's what came back:

<?xml version="1.0"?>

<methodResponse>
  <params>
  <param>
    <value><array><data>
</data></array></value>
  </param>
  </params>
</methodResponse>

Obviously this isn't quite right.. I dug through the code, adding print and print_r statements where I thought they might help, until I came to blogapi.module line 937 which says:

$available_types = array_keys(array_filter(variable_get('blogapi_node_types', array('blog' => 1))));

This is supposed to grab the blogapi_node_types system variable which stores a list of the Drupal content types you told it were allowed to be written to using the BlogAPI.. and I had set them, right?

200904201148.jpg

No, as it turned out I hadn't, though I thought I had.

Once I went to /admin/settings/blogapi I was able to mark a few content types to be editable, hit save, go back to ecto and finally see what I wanted:

200904201147.jpg

Success!


Ok, so next problem.. I wrote the above, including the two pasted images, hit Publish but started getting the following error:

<?xml version="1.0"?>
<methodResponse>
  <fault>
  <value>
   <struct>
   <member>
   <name>faultCode</name>
   <value><int>1</int></value>
   </member>
   <member>
   <name>faultString</name>
   <value><string>It is not possible to upload the file, because it exceeded the maximum filesize of 0 bytes.</string></value>
   </member>
   </struct>
  </value>
  </fault>
</methodResponse>

Obviously a problem persisted.

I cranked open the files and inserted some extra code that made it say::

<?xml version="1.0"?>
<methodResponse>
  <fault>
  <value>
   <struct>
   <member>
   <name>faultCode</name>
   <value><int>1</int></value>
   </member>
   <member>
   <name>faultString</name>
   <value><string>It is not possible to upload the file, because it exceeded the maximum filesize of 0 bytes and your file was 12.04 KB.</string></value>
   </member>
   </struct>
  </value>
  </fault>
</methodResponse>

From this you can see that it was getting the file, but it was basically saying that my account was not set up to accept attachments, which was not true as I was the administrator and could do everything, right?

I went back to the BlogAPI settings page, ensured that the file settings looked correct..

200904201211.jpg

.. scratched my head. Then I went to look at the permissions.. as it turned out I had not enabled "administer content with blog api" for my user group.

200904201212.jpg

Doh. I enabled that permission, saved it, and now when I went back to the BlogAPI settings page there was a new item waiting for me:

200904201210.jpg

I expanded that, set the same 1MB and 5MB... and saved..

Et voila! That did the trick, I can now post embedded images too!

5 Comments

Thanks so much... solved in

Thanks so much... solved in 10 min. instead 3 hours I spent yest.

I is still not working for

I is still not working for me.
I have done all that is described here, and I still got the following message

It is not possible to upload the file, because it exceeded the maximum filesize of 0 bytes.

When uploading torcicolo-dor-pescoco-cervicalgia-thumb.jpg.

Please contact the site's administrator for more assistance.

Any suggestions ??
Thanks a lot !

I too was scratching my head

I too was scratching my head for a long time before I stumbled upon your solution. Many thanks.... it was something I'd never even thought of checking!

Cheers!

Excellent tip! I had both

Excellent tip! I had both problems and now I don't. I am still stuck on one thing though. Is there a way in ecto (or any blogging client) to mark an entry as either published or not published? We follow an approval process with our blog posts and I want to post something as unpublished and then the editor will review and mark as published later...

This is cool – I didn’t know

This is cool – I didn’t know that you could use ecto from our laptop instead of the web interface through Drupal!! It is really helpful when we get informative tips like these which make so many things possible by just using the necessary plugins or modules!! With the tutorial given here and the steps to step detailed explanation, has helped me and I am thrilled to finally find a solution which was driving me crazy – keep up the good work!!angies list

How to reply

Care to add your own 2 cents? Let me know via Twitter or my contact page.