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

Source for file Stories.php

Documentation is available at Stories.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Stories endpoint driver
  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_Stories
  27.  *  
  28.  * @category    Services
  29.  * @package     Services_Digg
  30.  * @author      Joe Stump <joe@joestump.net>
  31.  */
  32. {
  33.     /**
  34.      * __call
  35.      *
  36.      * @access      public
  37.      * @param       string      $function       API endpiont to call
  38.      * @param       array       $args 
  39.      * @throws      Services_Digg_Exception
  40.      */
  41.     public function __call($functionarray $args
  42.     {
  43.         $endPoint '/stories/' $function;
  44.         $params = array();
  45.         if (isset($args[0]&& is_array($args[0])) {
  46.             $params $args[0];
  47.         }
  48.         
  49.         return $this->sendRequest($endPoint$params);
  50.     }
  51.  
  52.     /**
  53.      * Get all stories
  54.      *
  55.      * @access      public
  56.      * @param       array       $params     Digg API arguments
  57.      * @throws      Services_Digg_Exception
  58.      */
  59.     public function getAll(array $params = array())
  60.     {
  61.         return $this->sendRequest('/stories'$params);
  62.     }
  63.  
  64.     /**
  65.      * Get a single story by ID
  66.      *
  67.      * @access      public
  68.      * @param       int         $id         ID of story
  69.      * @param       array       $params     API parameters
  70.      * @throws      Services_Digg_Exception
  71.      */
  72.     public function getStoryById($idarray $params = array()) 
  73.     {
  74.         $result $this->sendRequest('/story/' $id$params);
  75.         return $result->stories[0];
  76.     }
  77.  
  78.     /**
  79.      * Get a single story by title
  80.      *
  81.      * @access      public
  82.      * @param       string      $title      Clean title of story
  83.      * @param       array       $params     API parameters
  84.      * @throws      Services_Digg_Exception
  85.      */
  86.     public function getStoryByTitle($titlearray $params = array())
  87.     {
  88.         $result $this->sendRequest('/story/' $title$params);
  89.         return $result->stories[0];
  90.     }
  91.  
  92.     /**
  93.      * Get a list of stories by their ID's
  94.      *
  95.      * @access      public
  96.      * @param       array       $stories    An array of story ID's
  97.      * @param       array       $params     Digg API arguments
  98.      * @throws      Services_Digg_Exception
  99.      */
  100.     public function getStoriesById(array $storiesarray $params = array()) 
  101.     {
  102.         $endPoint '/stories/' implode(','$stories);
  103.         return $this->sendRequest($endPoint$params);
  104.     }
  105.  
  106.     /**
  107.      * Get a list of stories' comments
  108.      *
  109.      * @access      public
  110.      * @param       array       $stories    An array of story ID's
  111.      * @param       array       $params     Digg API arguments
  112.      * @throws      Services_Digg_Exception
  113.      */
  114.     public function getStoriesComments(array $storiesarray $params = array())
  115.     {
  116.         $endPoint '/stories/' implode(','$stories'/comments';
  117.         return $this->sendRequest($endPoint$params);
  118.     }
  119.  
  120.     /**
  121.      * Get a list of stories' diggs
  122.      *
  123.      * @access      public
  124.      * @param       array       $stories    An array of story ID's
  125.      * @param       array       $params     Digg API arguments
  126.      * @throws      Services_Digg_Exception
  127.      */
  128.     public function getStoriesDiggs(array $storiesarray $params = array())
  129.     {
  130.         $endPoint '/stories/' implode(','$stories'/diggs';
  131.         return $this->sendRequest($endPoint$params);
  132.     }
  133.  
  134.     /**
  135.      * Get stories by container
  136.      *
  137.      * @access      public
  138.      * @param       string      $container  Name of container (ie. Sports)
  139.      * @param       array       $params     Digg API arguments
  140.      * @throws      Services_Digg_Exception
  141.      */
  142.     public function getContainer($containerarray $params = array()) 
  143.     {
  144.         $endPoint '/stories/container/' $container;
  145.         return $this->sendRequest($endPoint$params);
  146.     }
  147.  
  148.     /**
  149.      * Get top stories by container
  150.      *
  151.      * @access      public
  152.      * @param       string      $container  Name of container (ie. Sports)
  153.      * @param       array       $params     Digg API arguments
  154.      * @throws      Services_Digg_Exception
  155.      */
  156.     public function getContainerTop($containerarray $params = array())
  157.     {
  158.         $endPoint '/stories/container/' $container '/top';
  159.         return $this->sendRequest($endPoint$params);
  160.     }
  161.  
  162.     /**
  163.      * Get hot stories by container
  164.      *
  165.      * @access      public
  166.      * @param       string      $container  Name of container (ie. Sports)
  167.      * @param       array       $params     Digg API arguments
  168.      * @throws      Services_Digg_Exception
  169.      */
  170.     public function getContainerHot($containerarray $params = array())
  171.     {
  172.         $endPoint '/stories/container/' $container '/hot';
  173.         return $this->sendRequest($endPoint$params);
  174.     }
  175.  
  176.     /**
  177.      * Get popular stories in a specific container
  178.      *
  179.      * @access      public
  180.      * @param       string      $container  Name of container (ie. Sports)
  181.      * @param       array       $params     Digg API arguments
  182.      * @throws      Services_Digg_Exception
  183.      */
  184.     public function getContainerPopular($containerarray $params = array()) 
  185.     {
  186.         $endPoint '/stories/container/' $container '/popular';
  187.         return $this->sendRequest($endPoint$params);
  188.     }
  189.  
  190.     /**
  191.      * Get upcoming stories in a specific container
  192.      *
  193.      * @access      public
  194.      * @param       string      $container  Name of container (ie. Sports)
  195.      * @param       array       $params     Digg API arguments
  196.      * @throws      Services_Digg_Exception
  197.      */
  198.     public function getContainerUpcoming($containerarray $params = array()) 
  199.     {
  200.         $endPoint '/stories/container/' $container '/upcoming';
  201.         return $this->sendRequest($endPoint$params);
  202.     }
  203.  
  204.     /**
  205.      * Get stories in a specific topic
  206.      *
  207.      * @access      public
  208.      * @param       string      $topic      Name of topic (ie. Apple)
  209.      * @param       array       $params     Digg API arguments
  210.      * @throws      Services_Digg_Exception
  211.      */
  212.     public function getTopic($topicarray $params = array()) 
  213.     {
  214.         $endPoint '/stories/topic/' $topic;
  215.         return $this->sendRequest($endPoint$params);
  216.     }
  217.  
  218.     /**
  219.      * Get top stories by topic
  220.      *
  221.      * @access      public
  222.      * @param       string      $topic      Name of topic (ie. Apple)
  223.      * @param       array       $params     Digg API arguments
  224.      * @throws      Services_Digg_Exception
  225.      */
  226.     public function getTopicTop($topicarray $params = array())
  227.     {
  228.         $endPoint '/stories/topic/' $topic '/top';
  229.         return $this->sendRequest($endPoint$params);
  230.     }
  231.  
  232.     /**
  233.      * Get hot stories by topic
  234.      *
  235.      * @access      public
  236.      * @param       string      $topic      Name of topic (ie. Apple)
  237.      * @param       array       $params     Digg API arguments
  238.      * @throws      Services_Digg_Exception
  239.      */
  240.     public function getTopicHot($containerarray $params = array())
  241.     {
  242.         $endPoint '/stories/topic/' $container '/hot';
  243.         return $this->sendRequest($endPoint$params);
  244.     }
  245.  
  246.     /**
  247.      * Get popular stories in a specific topic
  248.      *
  249.      * @access      public
  250.      * @param       string      $topic      Name of topic (ie. Apple)
  251.      * @param       array       $params     Digg API arguments
  252.      * @throws      Services_Digg_Exception
  253.      */
  254.     public function getTopicPopular($topicarray $params = array()) 
  255.     {
  256.         $endPoint '/stories/topic/' $topic '/popular';
  257.         return $this->sendRequest($endPoint$params);
  258.     }
  259.  
  260.     /**
  261.      * Get upcoming stories in a specific topic
  262.      *
  263.      * @access      public
  264.      * @param       string      $topic      Name of topic (ie. Apple)
  265.      * @param       array       $params     Digg API arguments
  266.      * @throws      Services_Digg_Exception
  267.      */
  268.     public function getTopicUpcoming($topicarray $params = array()) 
  269.     {
  270.         $endPoint '/stories/topic/' $topic '/upcoming';
  271.         return $this->sendRequest($endPoint$params);
  272.     }
  273.  
  274.     /**
  275.      * Get popular stories' comments
  276.      *
  277.      * @access      public
  278.      * @param       array       $params     Digg API arguments
  279.      * @return      object 
  280.      * @throws      Services_Digg_Exception
  281.      */
  282.     public function getPopularComments(array $params = array()) 
  283.     {
  284.         return $this->sendRequest('/stories/popular/comments'$params);
  285.     }
  286.  
  287.     /**
  288.      * Get all comments on upcoming stories
  289.      *
  290.      * @access      public
  291.      * @param       array       $params     API arguments
  292.      * @return      object 
  293.      * @throws      Services_Digg_Exception
  294.      */
  295.     public function getUpcomingComments(array $params = array())
  296.     {
  297.         return $this->sendRequest('/stories/upcoming/comments'$params);
  298.     }
  299.  
  300.     /**
  301.      * Get popular stories' diggs
  302.      *
  303.      * @access      public
  304.      * @param       array       $params     Digg API arguments
  305.      * @throws      Services_Digg_Exception
  306.      */
  307.     public function getPopularDiggs(array $params = array())
  308.     {
  309.         return $this->sendRequest('/stories/popular/diggs'$params);
  310.     }
  311.  
  312.     /**
  313.      * Get upcoming stories' diggs
  314.      *
  315.      * @access      public
  316.      * @param       array       $params     Digg API arguments
  317.      * @throws      Services_Digg_Exception
  318.      */
  319.     public function getUpcomingDiggs(array $params = array())
  320.     {
  321.         return $this->sendRequest('/stories/upcoming/diggs'$params);
  322.     }
  323. }
  324.  
  325. ?>

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