Introduction
PhpDelicious is a PHP 5 library for accessing the del.icio.us API. It combines data from the main REST and JSON APIs and presents a consolidated interface. It also implements a file based caching system which elimnates the need to query on every request and ensures access to the API won't be throttled due to excessive requests.
Requirements
- PHP 5 (sorry PHP 4 support has now been dropped)
- CURL (or can use normal file reading functions if suitable URL wrappers installed)
- json_decode function for JSON API based methods (native in PHP 5.2 and above)
- XML Parser Functions
Set Up
Setting up PhpDelicious is easy simply copy it to a suitable directory on your server. By default it writes it's cache files to /tmp/. If you don't have access to this directory (perhaps because you're using a shared hosting account) you'll need to create a new temporary directory and update the corresponding constant in php-delicious.inc.php (line 63).
define('PHP_DELICIOUS_CACHE_PATH', '/tmp/');
Rate Limiting
PhpDelicious limits the number of requests made to the del.icio.us API to one per second (as required by del.icio.us). For read only requests it does this via file based caching and, to all intensive purposes, this is transparent to the end user. It's unlikely your data will change that often. For requests which write to the API it implements a delay mechanism. The delay is selective and is only applied if at least one second hasn't elapsed between consecutive requests.
Public Methods
Constructor
__construct(string $sUsername, string $sPassword)
Example
<?phprequire('php-delicious.inc.php');$oPhpDelicious = new PhpDelicious('your-user', 'your-pass');?>
LastErrorNo
int LastErrorNo()
LastError
int LastError()
Alias for LastErrorNo(), retained for backwards compatibility.
LastErrorString
string LastErrorString()
GetLastUpdate
string GetLastUpdate()
Method returns false on failure.
GetAllTags
array GetAllTags()
Method returns false on failure.
RenameTag
bool RenameTag(string $sOld, string $sNew)
Method returns false on failure.
GetPosts
array GetPosts([string $sTag [, string $sDate [, string $sUrl]]])
Method returns false on failure.
GetRecentPosts
array GetRecentPosts([string $sTag [, int $iCount]])
Returns up to 15 posts by default. Method returns false on failure.
GetAllPosts
array GetAllPosts([string $sTag])
Method returns false on failure.
GetDates
array GetDates([string $sTag])
Method returns false on failure.
AddPost
bool AddPost(string $sUrl, string $sDecription [, string $sNotes [, array $aTags
[, string $sDate [, bool $bReplace]]]])
Method returns true on success, false on failure.
DeletePost
bool DeletePost(string $sUrl)
Method returns true on success, false on failure.
GetAllBundles
array GetAllBundles()
Method returns false on failure.
AddBundle
bool AddBundle(string $sName, array $aTags)
Method returns true on success, false on failure.
DeleteBundle
bool DeleteBundle(string $sName)
Method returns true on success, false on failure.
GetUrlDetails
array GetUrlDetails(variant $vUrls)
Takes a single URL or an array of URLs. Method returns false on failure.
GetNetwork
array GetNetwork(string $sUsername)
Method returns false on failure.
GetMyNetwork
array GetMyNetwork()
Method returns false on failure.
GetFans
array GetFans(string $sUsername)
Method returns false on failure.
GetMyFans
array GetMyFans()
Method returns false on failure.
License
PhpDelicious is covered by a liberal BSD license (which is outlined below).
Software License Agreement (BSD License)
Copyright (C) 2005-2008, Edward Eliot.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Edward Eliot nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission of Edward Eliot.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If you've unsure whether or not your proposed use of PhpDelicious is covered under this license please contact me.
Related Blog Posts
Download
Download a ZIP of PhpDelicious or, if you use Bazaar, checkout from the public repository.