Return to Snippet

Revision: 21466
at December 14, 2009 08:44 by stephanepericat


Updated Code
<?php

/**
 * Delicious_query();
 * @author: Stephane P. Pericat
 * @date: 2009-12-14
 * 
 * @param : $credentials(array), $request(string)
 * @return: simpleXML object
 */
function delicious_query($credentials = array(), $request) {
    if(empty($credentials)) {
        throw new InvalidArgumentException("no credentials provided");
    }
    
    $username = $credentials["username"];
    $password = $credentials["password"];
    $base_url = "https://".$username.":".$password."@api.del.icio.us/v1/";
    $full_url = $base_url.$request;
    
    $ch = curl_init($full_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $query = curl_exec($ch);
    curl_close($ch);
    
    return simplexml_load_string($query);
}

$creds = array("username" => "your_username",
               "password" => "your_password");

$query = delicious_query($creds, "posts/all?tag=php");
var_dump($query);

Revision: 21465
at December 14, 2009 05:56 by stephanepericat


Initial Code
<?php

/**
 * Delicious_query();
 * @author: Stephane P. Pericat
 * @date: 2009-12-14
 * 
 * @param : $credentials(array), $request(string)
 * @return: simpleXML object
 */
function delicious_query($credentials = array(), $request) {
    if(empty($credentials)) {
        throw new InvalidArgumentException("no credentails provided");
    }
    
    $username = $credentials["username"];
    $password = $credentials["password"];
    $base_url = "https://".$username.":".$password."@api.del.icio.us/v1/";
    $full_url = $base_url.$request;
    
    $ch = curl_init($full_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $query = curl_exec($ch);
    curl_close($ch);
    
    return simplexml_load_string($query);
}

$creds = array("username" => "your_username",
               "password" => "your_password");

$query = delicious_query($creds, "posts/all?tag=php");
var_dump($query);

Initial URL


Initial Description
an easy-to-use function to connect to your del.icio.us account and perform a query.
query commands can be found on their api help: http://delicious.com/help/api

Initial Title
Delicious query function

Initial Tags
curl, php

Initial Language
PHP