topical media & game development

talk show tell print

mashup-delicious-13-rally2007-save-popup.php / php



  <?php
  //configure del.icio.us username and password
  define('DELICIOUS_USERNAME','USERNAME');
  define('DELICIOUS_PASSWORD','PASSWORD');
  
  //bring in the Snoopy and configure
  require('lib/Snoopy.class.php');
  
  //bring in del.icio.us mashups lib
  require('lib/delicious_mashups.inc.php');
  
  //the default tag meant to identify all posts to the rally project
  define('DEFAULT_TAG',"rally2007");
  
  if (isset(_POST['Save'])) {
      response = ''; //will contain the success/error message from posting
      
      //assemble API method arguments
      arguments = '';
      
      //url
      if (_POST['url'] != "")
          arguments .= "&url=".urlencode(_POST['url']);
      else
          die("Sorry - URL is required!");
      
      //description
      if (_POST['description'] != "")
          arguments .= "&description=".urlencode(_POST['description']);
      else
          die("Sorry - title is required!");
      
      //extended
      arguments .= "&extended=".urlencode(_POST['extended']);
      
      //tags - consists of the default tag and whatever category was selected
      arguments .= "&tags=".urlencode(DEFAULT_TAG." "._POST['category']);
          
      //save the link to del.icio.us
      do_api_call('/posts/add?',arguments);
      
      //set response to indicate whether we got a favorable response or not
      if (api_return['status'] != 200)
          response = "Sorry, but there was an error. Code: ".api_return['status'];
      else
          response = "Saved succesfully!";
  }
  
  ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  
  <title>Save to Rally Website</title>
  
  </head>
  
  <body>
  
  <h3>Save this page to the Rally project website.</h3>
  
  <?php
  if (!isset(response)) {
  ?>
  <table width="100%">
  <tbody>
  <form method="post" accept-charset="utf-8">
      <tr>
          <td style="text-align: right">
              URL:
          </td>
          <td>
          <input type="text" name="url" size="60"
              value="<?php if (isset(_GET['location'])) { echo _GET['location']; }?>" />
          </td>
      </tr>
      <tr>
          <td style="text-align: right">
              Title:
          </td>
          <td>
          <input type="text" name="description" size="60"
              value="<?php if (isset(_GET['title'])) { echo _GET['title']; }?>" />
          </td>
      </tr>
      <tr>
          <td style="text-align: right">
              Notes:
          </td>
          <td>
          <textarea name="extended" cols="50" rows="5"></textarea>
          </td>
      </tr>
      <tr>
          <td style="text-align: right">
              Category:
          </td>
          <td>
          <select name="category">
              <option>Vendors</option>
              <option>Restaurants</option>
              <option>Hotels</option>
              <option>Services</option>
              <option>Sponsor</option>
              <option>Other</option>
          </select>
          </td>
      </tr>
      <tr>
          <td style="text-align: right" colspan="2">
              <input type="button" value="Cancel" onclick="window.close()" />
              <input type="submit" name="Save" value="Save" />
          </td>
      </tr>
  </form>
  </tbody>
  </table>
  <?php
  } else {
  ?>
      <div><?php echo response; ?></div>
      <div align="center">
          <a href="#" onclick="window.close()">[ Close this Window ]</a>
      </div>
  <?php
  }
  ?>
  </body>
  </html>
  


(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.