2007-12-24 / 14:02 / dave

In a combined quest to edit this blog from Emacs and stay super-cool, I’ve been trying to get atompub working on Wordpress 2.3.1 hosted on Dreamhost.

Will it work? Will I master the Atompub standard? Am I typing this in the world’s best editor?

Spoiler: NO

Read on for the thrilling details…

All I need to do is get to the damn URL

I started with the Wordpress AtomPub page in the Codex which recommends testing with Tim Bray’s APE. Time to first error: 5 seconds.

A typo in the codex said the end point was http://[Blog URL]/wp-app.php service. Er, that’s probably not a space, huh? I do the right thing and fix it.

The right URL still gave either a 404 or the extremely helpful “No input file specified” (I forget which condition produced which). Googling for “No input file specified” brought up this helpful number. I had already checked that Dreamhost was running PHP as CGI, so the error means that something is not getting forwarded right.

Well it looks like Wordpress Atompub might not work with PHP4, so I switched Dreamhost to PHP5:

Dreamhost: how to change PHP version

Now I can surf to the URL and, thanks to the magic of the “cookies give you permission” hack inside wp-app.php and

<?xml version="1.0" encoding="utf-8" ?>
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title>WordPress Workspace</atom:title>
    <collection href="http://ndanger.org/blog/wp-app.php/posts">
      <atom:title>WordPress Posts</atom:title>
      <accept>application/atom+xml;type=entry</accept>
      <categories href="http://ndanger.org/blog/wp-app.php/categories" />
    </collection>
    <collection href="http://ndanger.org/blog/wp-app.php/attachments">
      <atom:title>WordPress Media</atom:title>
      <accept>image/*</accept>
      <accept>audio/*</accept>
      <accept>video/*</accept>
    </collection>
  </workspace>
</service>

Hooray!

Mere steps away

Predictably, APE gives me an authorization error

APE credentials required screen shot

That’s covered in the codex. Unfortunately, neither the “HTTP Authentication with PHP” suggestion the codex links to or Joseph Scott’s get hack works.

Time to turn on logging in wp-app.php, and tail -f wp-app.log.

Maybe the rewrite rule isn’t getting applied? A test–by forwarding to my about page–works, so the rule is getting applied. Maybe the environment hacking isn’t working, so I redirect to a test script:

<?
$agent       = $_SERVER['HTTP_USER_AGENT'];
$ip          = $_SERVER['REMOTE_ADDR'];
$port        = $_SERVER['REMOTE_PORT'];
$d           = date ('dS \of F Y h:1:s A');
$ha          = $_SERVER['HTTP_AUTHORIZATION'];

echo "Your IP : $ip<br>";
echo "You are using : $agent<br>";
echo "You are connected through port : $port<br>";
echo "Today is : $d<br>";
echo "HTTP_AUTHORIZATION : $ha<br>";
echo "<br>_SERVER:<br>";
foreach ($_SERVER as $key => $value) {
  echo "$key: $value<br>";
}
echo "<br>_ENV:<br>";
foreach ($_ENV as $key => $value) {
  echo "$key: $value<br>";
}
echo "<br>_GET:<br>";
foreach ($_GET as $key => $value) {
  echo "$key: $value<br>";
}
?>

Both hacks seem to work in theory, except that the header I need–HTTP_AUTHORIZATION–seems to be absent, even if I use curl to manually set the headers using the example in the RFC.

More googling turns up the blocking of BasicAuth in WinXP SP2. Enable that. Nothing.

By now it’s 4 am and I’m still starting at a 404, so I post to the Dreamhost support forums.

And you got an answer, right?

Nah. That was all 3 days ago, so now I submitted a help ticket to the support staff. Have’t heard anything back yet, but that’s probably because I marked it as “Hey, it’d be nice, but it’s not holding me up”.

Anyone got any suggestions? I was going to set up a test directory and see if Apache’s .htaccess authentication–in BasicAuth mode–works.

In the meantime I’ll try out XML-RPC… it looks like there’s even an Emacs package.


UPDATE:

Heard back from dreamhost:

Hello,

Unfortunately, I’m not sure what would cause this, however, we can’t
really provide support for custom scripting, or custom mod_rewrite rules.
Sorry about that.

If you need anything else, please let us know.

Thanks!
Brian