Source for file php.php
Documentation is available at php.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* API for Digg's web services
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
* @author Joe Stump <joe@joestump.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @link http://pear.php.net/package/Services_Digg
require_once 'Services/Digg/Response/Common.php';
* Services_Digg_Response_php
* Parses the PHP response type from the Digg API. Digg's API responds with
* PHP, JSON and XML currently.
* @author Joe Stump <joe@joestump.net>
* @return mixed DiggAPIError on failure
throw new Services_Digg_Response_Exception ('Could not parse result');
throw new Services_Digg_Response_Exception ($result->message , $result->code );
require_once 'Services/Digg/Story.php';
* @author Joe Stump <joe@joestump.net>
* @see Services_Digg_Story
public function __call($function, array $args)
if (isset ($args[0 ]) && is_array ($args[0 ]) && count ($args[0 ])) {
return parent ::__call($function, array ($this->id , $params));
* Get comment activity for a story
* @param array $params Digg API arguments
* Get digg activity for a story
* @param array $params Digg API arguments
require_once 'Services/Digg/GalleryPhoto.php';
* @author Joe Stump <joe@joestump.net>
* @see Services_Digg_GalleryPhoto
* Make a second service call
* @param string $function
public function __call($function, array $args)
if (isset ($args[0 ]) && is_array ($args[0 ]) && count ($args[0 ])) {
return parent ::__call($function, array ($this->id , $params));
* @author Joe Stump <joe@joestump.net>
* @var string $message Error message
* @var int $code Error code
* @return string Error message
require_once 'Services/Digg/User.php';
* @author Joe Stump <joe@joestump.net>
* @see Services_Digg_User
* @param string $function
public function __call($function, array $args)
if (isset ($args[0 ]) && is_array ($args[0 ]) && count ($args[0 ])) {
return parent ::__call($function, array ($this->name , $params));
* Get a user's comment activity
* Get a user's digg activity
* Is the user friends with a person
* @param string $friend Username to check for
return parent ::isFan($this->name , $friend);
* Is the person a fan of this user
* @param string $fan Username to check for
public function isFan($fan)
return parent ::isFan($this->name , $fan);
* Get a user's friends' submissions
* @throws Services_Digg_Exception
$endPoint = '/user/' . $this->name . '/friends/submissions';
* Get a user's friends' dugg stories
* @throws Services_Digg_Exception
$endPoint = '/user/' . $this->name . '/friends/dugg';
* Get a user's friends' commented stories
* @throws Services_Digg_Exception
$endPoint = '/user/' . $this->name . '/friends/commented';
* Get a user's friends' popular stories that they dugg
* @throws Services_Digg_Exception
$endPoint = '/user/' . $this->name . '/friends/popular';
* Get a user's friends' upcoming stories that they dugg
* @throws Services_Digg_Exception
$endPoint = '/user/' . $this->name . '/friends/upcoming';
require_once 'Services/Digg/Comment.php';
* @author Joe Stump <joe@joestump.net>
* @see Services_Digg_Comment
* Get a comment's replies
* This function returns replies to the current comment. It only makes
* the second API call if the reply count is greater than zero.
* @param array $params Digg API arguments
* @return object Instance of DiggAPIEvents
public function replies(array $params = array ())
if ($this->replies > 0 ) {
$endPoint = '/story/' . $this->story . '/comment/' . $this->id .
$ret->timestamp = time();
$ret->total = $ret->offset = $ret->count = 0;
* @return string Comment's content
* @author Joe Stump <joe@joestump.net>
* @author Joe Stump <joe@joestump.net>
* Return current element of $activity
* Return a key from $activity array
return key($this->activity);
* Advance the internal pointer of $activity array
return next($this->activity);
* Is the next iteration valid?
return ($this->current() !== false );
* @author Joe Stump <joe@joestump.net>
* @author Joe Stump <joe@joestump.net>
* @author Joe Stump <joe@joestump.net>
* Return current element of $errors
* Return a key from $errors array
return key($this->errors);
* Advance the internal pointer of $errors array
return next($this->errors);
* Is the next iteration valid?
return ($this->current() !== false );
* @author Joe Stump <joe@joestump.net>
* The DiggAPIEvents class is returned for both comments and diggs.
* In order for PHP5 object iteration to happen we need to figure out
* which events are returned (diggs v. comments) and iterate through
private $iterator = null;
* When this is unserialized we check to see if the events listed
* are diggs or comments and then set $iterator appropriately.
* @see DiggAPIEvents::$iterator
if (isset ($this->diggs) &&
$this->iterator = 'diggs';
} elseif (isset ($this->comments) &&
$this->iterator = 'comments';
reset($this->{$this->iterator});
|