Finished Updates to WordIdentica Plugin

I finished with my testing and hacking on Blue Fur’s excellent WordPress plugin for sending posts to Identi.ca as status updates. The problems I was having were not with the original code but with WordPress.

The change to get the plugin to work with ur1.ca were pretty straightforward. Thanks to Zach again for providing the initial code I used. I had to make a couple of changes to get it working as I needed, mostly setting a particular CURL option to get the response from ur1.ca where I needed it and a simplification of the XPath expression to get at the shortened URL. My sources have comments pointing out those two changes.

For the weird quote handling problem I was encountering it, it was actually caused by WordPress changing quotes in post titles into cutesy directional quotes. That means a simple " gets changed into a string of characters like “. This isn’t bad, per se, except that the leading ampersand was truncating the post field for the status message. A URL encode fixed that but revealed that Identi.ca is escaping the leading ampersand, making the quote appear as that gobbledy-gook string. That’s the right thing for them to do, escaping user entered text helps foil injection attacks. It was uglying up my status messages, though.

So I added a little function into the plugin to find those named entities and just turn them back into plain ASCII quotes and single quotes. I pass that through a URL encode to avoid the message truncation and now everything appears in Identi.ca as I prefer it.

You can download my version of the plugin, if you like. Blue Fur did not appear to attach a license, neither did I. I provide my changes without condition on re-use but as-is with no warranties.

2 Replies to “Finished Updates to WordIdentica Plugin”

  1. Any ideas why I am getting this error?
    Warning: domdocument() expects at least 1 parameter, 0 given in /home/.elijah/portinga/food.upmykilt.net/wp-content/plugins/wordidentica/wordidentica.php on line 42

    Fatal error: Call to undefined function: loadhtml() in /home/.elijah/portinga/food.upmykilt.net/wp-content/plugins/wordidentica/wordidentica.php on line 43

    dent me at mcnee if you can help.

  2. If I had to guess, I’d say it was a result of you using a different version of PHP. I am using PHP5, specifically 5.2.3 I think. I had some problems with the code Zach original sent me and those problems seem to have been a result of a different version between him and me as well.

    According to PHP.net, the constructor for DOMDocument has two arguments but they are both optional.

    http://us2.php.net/manual/en/class.domdocument.php

    I don’t know how to get at the version of the document for PHP4 to see what the constructor expects there, if you are unable to upgrade. You might simply try adding a version string, “1.0”, as the first argument and an encoding, “utf-8” or “iso-8859-1”, and see if that fixes it. Or upgrade to PHP5 if you can.

Leave a Reply

Your email address will not be published. Required fields are marked *