Services_Digg
[ class tree: Services_Digg ] [ index: Services_Digg ] [ all elements ]

Source for file Story.php

Documentation is available at Story.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Story class for Digg API
  7.  *
  8.  * PHP version 5.1.0+
  9.  *
  10.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  11.  * that is available through the world-wide-web at the following URI:
  12.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  13.  * the PHP License and are unable to obtain it through the web, please
  14.  * send a note to license@php.net so we can mail you a copy immediately.
  15.  *
  16.  * @category    Services
  17.  * @package     Services_Digg
  18.  * @author      Joe Stump <joe@joestump.net>
  19.  * @copyright   1997-2007 The PHP Group
  20.  * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
  21.  * @version     CVS: $Id:$
  22.  * @link        http://pear.php.net/package/Services_Digg
  23.  */
  24.  
  25. /**
  26.  * Services_Digg_Story
  27.  *  
  28.  * @category    Services
  29.  * @package     Services_Digg
  30.  * @author      Joe Stump <joe@joestump.net>
  31.  */
  32. {
  33.     /**
  34.      * __call
  35.      *
  36.      * Any function you call via this (ie. comments()) requires you to pass
  37.      * a numeric story ID. The optional second argument is the normal $params
  38.      * argument passed to most API calls.
  39.      *
  40.      * @access      public
  41.      * @param       string      $function 
  42.      * @param       array       $args 
  43.      * @throws      Services_Digg_Exception
  44.      */
  45.     public function __call($functionarray $args)
  46.     {
  47.         if (!isset($args[0]|| !is_numeric($args[0])) {
  48.             throw new Services_Digg_Exception('First argument must be numeric');
  49.         
  50.  
  51.         $story $args[0];
  52.  
  53.         $params = array();
  54.         if (isset($args[1]&& is_array($args[1]&& count($args[1])) {
  55.             $params $args[1];
  56.         }
  57.  
  58.         $endPoint '/story/' $story '/' $function;
  59.         return $this->sendRequest($endPoint$params);
  60.     }
  61.  
  62.     /**
  63.      * Get comment activity for a story
  64.      * 
  65.      * @access      public
  66.      * @param       int         $story      Story ID
  67.      * @param       array       $params     Digg API arguments
  68.      * @throws      Services_Digg_Exception
  69.      */
  70.     public function getCommentActivity($storyarray $params = array())
  71.     {
  72.         $endPoint '/story/' $this->id . '/activity/comments';
  73.         return $this->sendRequest($endPoint$params);
  74.     }
  75.  
  76.     /**
  77.      * Get a specific comment on a story
  78.      *
  79.      * @access      public
  80.      * @param       int         $commentid  ID of comment to fetch
  81.      * @param       array       $params     Digg API arguments
  82.      * @throws      Services_Digg_Exception
  83.      */
  84.     public function getCommentById($commentidarray $params = array()) 
  85.     {
  86.         $endPoint '/story/' $this->id . '/comment/' $commentid;
  87.         $result $this->sendRequest($endPoint$params);
  88.         return $result->comments[0];
  89.     }
  90.  
  91.     /**
  92.      * Get digg activity for a story
  93.      * 
  94.      * @access      public
  95.      * @param       int         $story      Story ID
  96.      * @param       array       $params     Digg API arguments
  97.      * @throws      Services_Digg_Exception
  98.      */
  99.     public function getDiggActivity($storyarray $params = array())
  100.     {
  101.         $endPoint '/story/' $this->id . '/activity/diggs';
  102.         return $this->sendRequest($endPoint$params);
  103.     }
  104. }
  105.  
  106. ?>

Documentation generated on Tue, 04 Dec 2007 15:00:12 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.