Wordpress Daily Delicious Post

We've already discussed ways to include content from an RSS feed in the sidebar of your homepage or weblog, and how to pull in del.icio.us links using the RSS feed. But sometimes, you don't want the links to go to the sidebar: you want to actually show the links off to the world. Not everyone is going to read your del.icio.us links RSS feed, but if you make a daily post with them, there's a chance your readers will skim them and see something they like.

This is where Wordpress's del.icio.us Daily hack comes in. A script designed to be run as a cron job to post your daily links, this will let other users see the links you're bookmarking as an entry in your weblog.

Getting the Script

The Daily Delicious script has a wiki page http://wiki.dot-totally.co.uk/Daily_Delicious where links to the source can be found. The most up to date version of the script as of this writing is at http://rawsocket.org/wp-content/wp-images/delicious.txt. Like our other PHP based RSS hacks, this uses the Magpie RSS library, so you must install it before using this hack.

Configuring the Script

There are a number of variables which need confiruation before the script can be used. You will need to set the wp_path and magpie_path to the directories where these files are stored: for example, /home/crschmidt/www/blog/ and /home/crschmidt/www/magpierss. Your del.icio.us username should be stored in the $del_user variable.

The wp_userid and wp_catid variables must be obtained from the Wordpress admin interface. While logged into the admin section of your weblog, click Manage, then Categories. This will show a list of the categories on the blog, allowing you to choose one by the ID displayed alongside it. To find a user ID with which you wish to post, first click Users, then Authors and Users. This will allow you to find a user ID. Comment status, pingback status, title, and post slug can all be set as well.

Using the Script

Once you have edited the variables you wish to, you will need to run the script to test it. How you do this depends on what you have available for processing PHP. Many systems include a PHP command line interpreter: if this is true of your system, you will be able to run the script by simply typing:

    php delicious.php

at the commandline. However, if that is not the case, you will need to place the script in a web-accessible directory, and use something like curl to fetch the file:

    curl -s -o /dev/null http://example.com/delicious.php

However, since any time this script is hit, it will post all the links of the day, you should take care to ensure that this file is protected. One way to do this is to enabled Authentication against the location of the file: curl can then use a URL like http://username:password@example.com/delicious.php, so that random users can not post the links, but it can still be automated. For more on authentication in your webserver, please consult your webserver's documentation.

Final Setup

Once the script is in place as you want it, you can add a task to cron to post these links daily:

    55 23 * * * php /home/crschmidt/delicious.php

This will post the links at 11:55 PM every day, to get all the links from the day included.