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

Class: Services_Digg2

Source Location: /Services_Digg2-0.3.2/Services/Digg2.php

Class Overview


Services_Digg2


Author(s):

Copyright:

  • 2010 Digg, Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 71]
Services_Digg2

A simple pass-through layer for accessing Digg's second generation API.

Anonymous request for popular stories:

  1.  require_once 'Services/Digg2.php';
  2.  
  3.  $digg = new Services_Digg2;
  4.  try {
  5.      $results $digg->story->getPopular();
  6.  catch (Services_Digg2_Exception $e{
  7.      echo $e->getMessage();
  8.  }
  9.  
  10.  var_dump($results);

Authenticated request for digging a story

  1.  require_once 'Services/Digg2.php';
  2.  require_once 'HTTP/OAuth/Consumer.php';
  3.  
  4.  $digg  = new Services_Digg2;
  5.  $oauth = new HTTP_OAuth_Consumer('key''secret''token''token_secret');
  6.  $digg->accept($oauth);
  7.  
  8.  try {
  9.      $result $digg->story->digg(array('story_id' => 12345));
  10.  catch (Services_Digg2_Exception $e{
  11.      echo $e->getMessage();
  12.  }
  13.  
  14.  var_dump($result);

See http://digg.com/api for API documentation.



[ Top ]


Class Variables

$currentGroup =  null

[line 102]

Current group requested. i.e., $digg->story->getAll(), the group is "story".

Type:   string


[ Top ]

$HTTPOAuthConsumer =  null

[line 119]

Stores an instance of HTTP_OAuth_Consumer

Type:   HTTP_OAuth_Consumer|null


[ Top ]

$HTTPRequest2 =  null

[line 111]

Stores an optional custom instance of HTTP_Request2. Use this if you want to set HTTP_Request2 options, like timeouts, etc.

Type:   HTTP_Request2


[ Top ]

$lastResponse =  null

[line 147]

Last response object

Type:   HTTP_Request2_Response


[ Top ]

$uri =  'http://services.digg.com'

[line 80]

URI of API. You shouldn't need to change this unless you work at Digg.

Type:   string


[ Top ]

$version =  '2.0'

[line 87]

Version to use in API calls
  • Access: protected

Type:   mixed


[ Top ]

$versions = array('1.0', '2.0')

[line 94]

Supported version numbers
  • Access: protected

Type:   $versions


[ Top ]

$writeMethods = array(
        'story.digg',
        'story.bury',
        'story.hide',
        'comment.digg',
        'comment.bury',
        'comment.post',
        'user.follow',
        'user.unfollow',
        'getSavedStories',
        'saveStory',
        'removeStory',
        'oauth.verify'
    )

[line 126]

Methods that require POST and OAuth
  • Access: protected

Type:   array


[ Top ]



Method Detail

accept   [line 188]

void accept( mixed $object)

Accepts HTTP_OAuth_Consumer (for writeable endpoints), or a custom instance of HTTP_Request2. The latter is useful if you want to use custom config options, adapters, etc, for HTTP_Request2.

Parameters:

mixed   $object   —  HTTP_OAuth_Consumer instance or custom instance of HTTP_Request2

[ Top ]

getHTTPOAuthConsumer   [line 227]

void getHTTPOAuthConsumer( )

Gets $this->HTTPOAuthConsumer, regardless of whether it is set or not.
  • Access: public

[ Top ]

getHTTPRequest2   [line 211]

HTTP_Request2 getHTTPRequest2( )

Gets an instance of HTTP_Request2. If $HTTPRequest2 is not aleady set, an instance will be created, set, and returned.

[ Top ]

getLastResponse   [line 447]

HTTP_Request2_Response|null getLastResponse( )

Returns the last HTTP_Request2_Response object. Defaults to null if no API request has been made yet. Handy if you want to look at the X-RateLimit headers, like so:

  1.  require_once 'Services/Digg2.php';
  2.  
  3.  $digg    = new Services_Digg2;
  4.  $popular $digg->story->getPopular();
  5.  $current $digg->getLastResponse()->getHeader('X-RateLimit-current');
  6.  $max     $digg->getLastResponse()->getHeader('X-RateLimit-max');
  7.  $reset   $digg->getLastResponse()->getHeader('X-RateLimit-reset');
  8.  
  9.  echo "I've used $current of my $max allowed requests.  This rate limit period
  10.  resets in $reset seconds";

  • Access: public

[ Top ]

getURI   [line 172]

string getURI( )

Gets the Digg API URI
  • Access: public

[ Top ]

getVersion   [line 255]

string getVersion( )

Gets the current version setting (i.e. 1.0).

[ Top ]

setURI   [line 159]

void setURI( string $uri)

Sets the URI. You'll probably never use this unless you work at Digg.

Parameters:

string   $uri   —  The Digg API URI

[ Top ]

setVersion   [line 241]

void setVersion( mixed $version)

Sets the version of the API to use.

Parameters:

mixed   $version   —  Version to use, defaults to 1.0

[ Top ]

__call   [line 297]

result __call( string $name, [array $args = array()])

Concatenates the current group and a method, then adds it as the 'method' key of the arguments array, and finally passes to sendRequest(). No local validation is done. Any errors are passed back from the Digg API.

See http://digg.com/api for API documentation.

  • Return: of sendRequest()
  • See: Services_Digg2::__get()
  • Throws: Services_Digg2_Exception (indirectly) on anything but a 2XX response
  • Access: public

Parameters:

string   $name   —  Method name (i.e. getInfo())
array   $args   —  Array of arguments. 'method' key will be overwritten.

[ Top ]

__get   [line 277]

Services_Digg2 __get( string $group)

Represents an API "group", and provides a pass-through to __call().

The example below calls story.getInfo(). The object spacing is needed because member variables in PHP cannot have '.' in them.

  1.  $digg  = new Services_Digg2()
  2.  $story $digg->story->getInfo(array('story_id' => 12345));

See http://digg.com/api for API documentation.


Parameters:

string   $group   —  The name of the API "group"

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.