topical media & game development 
  
 
 
 
 
  
    
    
  
 mashup-delicious-07-delicious-summary2-lib-delicious-mashups.inc.php / php
  <?php
  //you must instantiate the Snoopy class first
  if (!class_exists('Snoopy'))
      die('Please include the Snoopy class library before delicious_mashups.inc.php is included.');
  
  //you also must define DELICIOUS_USERNAME and DELICIOUS_PASSWORD
  if (!defined('DELICIOUS_USERNAME') || !defined('DELICIOUS_PASSWORD'))
      die('Please make sure DELICIOUS_USERNAME and DELICIOUS_PASSWORD are set before delicious_mashups.inc.php is included.');
  //the base del.icio.us REST API URL
  
  define('DELICIOUS_API_URL',"https://api.del.icio.us/v1");
  
  //create a new Snoopy object
  snoopy->agent = "del.icio.us-Mashups-Library/1.0";
  snoopy->pass = DELICIOUS_PASSWORD;
  
  //give snoopy our path to cURL and where it should put downloaded files
  snoopy->temp_dir = '/tmp'; //Windows: C:\temp
  
  //hide notices as Snoopy generates some
  error_reporting(E_ERROR | E_WARNING | E_PARSE);
  
  method, api_return
      global api_return = array();
      
      //bring in snoopy
      global url = DELICIOUS_API_URL.query_string;
      
      //sleep for one second as per request
      sleep(1);
      
      //fetch the REST URL with snoopy
      if(url))
      {
          //snoopy doesn't set status with ssl requests, so lets do that here
          if (snoopy->status = get_status_from_response(snoopy->status == 200)
              parse_xml_results(api_return the status code
          snoopy->status;
      } else {
          //handle any snoopy errors by outputting them to the screen
          die("ERROR: ".response_code)
  {
      preg_match("|^HTTP/[^\s]*\s(.*?)\s|",status);
      return snoopy_results)
  {
      //bring in the 
      global api_return;
      
      //setup the parser and handlers
      parser, "process_start", "process_end");
      xml_set_character_data_handler(parsed = xml_parse(snoopy_results);
      if (!parser)." at line 
  ".xml_get_current_line_number(parser);
  }
  
  //handle the start of an XML element
  function process_start(name, api_return;
      name,"attributes"=>api_return,parser, api_return;
      api_return)-2]['children'][] = api_return)-1];
      array_pop(parser, api_return,cdata))
     {   
         api_return)-1]['cdata']=
  
  
(C) Æliens 
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.