summaryrefslogtreecommitdiff
path: root/wired/old/published/Webmonkey/APIs/delicious.txt
diff options
context:
space:
mode:
Diffstat (limited to 'wired/old/published/Webmonkey/APIs/delicious.txt')
-rw-r--r--wired/old/published/Webmonkey/APIs/delicious.txt45
1 files changed, 45 insertions, 0 deletions
diff --git a/wired/old/published/Webmonkey/APIs/delicious.txt b/wired/old/published/Webmonkey/APIs/delicious.txt
new file mode 100644
index 0000000..19d699d
--- /dev/null
+++ b/wired/old/published/Webmonkey/APIs/delicious.txt
@@ -0,0 +1,45 @@
+Del.icio.us started the social bookmarking revolution and it continues to a popular way to store and share your bookmarks with the world.
+
+Thanks to its API, it's relatively simple to retrieve your bookmarks and display them on your own site or mash them up somewhere else. And there's no need to limit yourself to your own bookmarks, you can grab bookmarks by tag, other users, date and half a dozen other means.
+
+As an example, we'll use the del.icio.us API to grab your recent bookmarks, however, if you want to grab something else, say a list of all your tags, you'll just need to change one line.
+
+== Getting Started ==
+
+There are a number of client libraries available for those looking to access the del.icio.us API. There's a particularly nice one for [http://code.google.com/p/pydelicious/ Python] and one for [http://delicious-java.sourceforge.net/ Java] as well.
+
+However we're going to skip the client in favor of writing our own code in PHP. The process is simple, just send your login credentials and then the url of the method you're trying to access.
+
+Copy this code into your PHP file.
+
+<?
+$dusername = "XXXXXXXXXXXXX";
+$dpassword = "XXXXXXXXXXXXX";
+$api = "api.del.icio.us/v1";
+$apicall = "https://$dusername:$dpassword@$api/posts/recent?&count=30";
+function del_connect($url) {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL,$url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
+ curl_setopt($ch, CURLOPT_USERAGENT, 'mycoolname');
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+ $xml = curl_exec ($ch);
+ curl_close ($ch);
+ return $xml;
+}
+$result = del_connect($apicall);
+echo $result;
+?>
+
+The first four lines just set up our URL to retrieve the last 30 bookmarks posted to your account. Naturally you can change this to access any of the [http://del.icio.us/help/api/ API methods] that del.icio.us offers.
+
+Once we have the URL in place we just pass it to our <code>del_connect()</code> which then uses PHP's built in cURL library to retrieve the XML data from del.icio.us.
+
+== Where to go from here ==
+
+So we have our last 30 bookmarks, but of course you'll need to parse that XML into some usable PHP structure, like an array, for displaying on a webpage. Since there are at least half a dozen XML parsers for PHP we'll leave that for you to decide.
+
+The other thing to keep in mind is that we haven't cached our results at all, so don't use this code in an actual web page or del.icio.us may well ban you. You need to set up some sort of cache -- Apache's mod_cache can fit the bill -- so that you don't pound on the del.icio.us servers every time your page refreshes.
+
+
+