del.icio.us proxy
Last updated: April 2, 2008
A way to save bookmarks to your del.icio.us account without going to the del.icio.us website itself.
What you will need
- A Web host that runs PHP 4 or PHP 5.
- The proxy code, which you can download below.
- Ed Eliot’s PhpDelicious library – Note: I had to tweak the code a little for this project, so one of the downloads below includes my modified version of PhpDelicious. In future, it’s probably best to check that you have the latest code from Ed’s site. See Notes for more information.
- A few minutes to set up.
Important! The newest version of the PhpDelicious library has dropped support for PHP 4, so if you have trouble using del.icio.us proxy with PhpDelicious, try downloading del.icio.us proxy with the older version of PhpDelicious below. However, it is highly recommended that everyone upgrades to using PHP 5 very soon; I will be updating the del.icio.us proxy code accordingly… when I find a few minutes to do it!
Download: del.icio.us proxy v1.1 – April 2, 2008
Change log
Installation
- Extract the files:
- Extract the proxy code to a directory – I will use “delicious/” for my examples.
- If you have downloaded the PhpDelicious library separately, extract its files to a subdirectory called “php-delicious” – mine is in “delicious/php-delicious/”.
- Open up the proxy settings (“delicious/settings.php”) and prepare your proxy:
- Change the “location” to be the URL on your site that’s going to act as your proxy. For example, something like “http://example.com/delicious/”. The URL must include a trailing forward slash.
// full location of this script on your server
define('LOCATION', 'http://example.com/delicious/');
- To stop other people using your proxy to save bookmarks to your del.icio.us account, you need to set a “key”. This will be used to identify yourself when using the proxy.
// set yourself a token (a "key") to identify yourself to the script when you wish to post
define('KEY', 'yourkey');
- The proxy will remember your del.icio.us username and password for you. Set up the username and password for your del.icio.us account.
// your del.icio.us username and password
define('DELICIOUS_USERNAME', 'username');
define('DELICIOUS_PASSWORD', 'password');
- Optionally, change any of the default optional settings as described in the settings.php file. These control the display of tags when posting, caching and additional anti-throttling protection.
- Upload the directory to the desired location on your host (e.g. “http://example.com/delicious/”).
Additional installation notes
- The main proxy code is all in the index.php file for ease of upgrading. Usually, this is the only file that will need upgrading.
- All your settings are, funnily enough, in the settings.php file so that you don’t have to set up all over again if you need to upgrade the proxy code.
- If you’re clever (or paranoid) and know how to include files out of Web root, you can further protect your del.icio.us account by storing these details, or the whole settings.php file, out of the Web root on your host.
Using the proxy
- Open up the location of your proxy in your browser. You will need to add “?key=yourkey” to the URL to be able to access the proxy the first time, something like “http://example.com/delicious/?key=yourkey”
- You’ll want a bookmarklet to make using your new proxy as easy as possible. Once you’re on your proxy page, you should see the del.icio.us proxy form. Pop down to the bottom of the page and hit the “del.icio.us proxy bookmarklet” link. This will generate a bookmarklet for you. Drag the bookmarklet to your browser’s bookmarks and try it out.
If you get any problems, give me a shout.
Change log
Soon: upgrading to PHP 5.
del.icio.us proxy v1.1 – April 2, 2008 (download)
- FIXED: Cleaned data now properly populates the form.
- FIXED: Tidied up after stupid markup issues; pages now validate.
- ADDED: Improved CSS styling.
- ADDED: Useful link to your del.icio.us profile.
Affects: form.thtml, index.php, s.css
del.icio.us proxy v1.0.1 – December 6, 2007
- FIXED: Bookmark description and extended notes no longer include escaped characters.
Affects: index.php
del.icio.us proxy v1.0 – October 31, 2007
- Initial release (call it a “beta”)
Notes
At time of writing, the PhpDelicious library needed a tweak before it would work properly. If you download my tweaked version of the library, you should be fine. However, if you decide to download the latest copy of the PhpDelicious code for use with the proxy, you may need to do these tweaks yourself.
It seems that the response data returned by the del.icio.us API has changed since the last version of the PhpDelicious code was released, or at least the response differs depending on situation. To get it to work reliably, I needed to change line 366 of the “php-delicious.inc.php” file:
// old code
//return $this->GetBoolReturn($aResult['content']);
// new code
if (isset($aResult['attributes']['CODE'])) {
return $this->GetBoolReturn($aResult['attributes']['CODE']);
} else if (isset($aResult['content'])) {
return $this->GetBoolReturn($aResult['content']);
} else {
// presume it failed?
return false;
}
Back to the Experiments index.
Back to the Lab index.