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

Class: Services_Akismet_HttpClient

Source Location: /Services_Akismet-1.0.1/Akismet/HttpClient.php

Class Overview


Abstract simple HTTP client for accessing the Akismet REST API


Author(s):

Copyright:

  • 2007-2008 Bret Kuhns, 2008 silverorange

Methods


Child classes:

Services_Akismet_HttpClient_Socket
Socket-based simple HTTP client for accessing the Akismet REST API
Services_Akismet_HttpClient_Stream
Streams-based simple HTTP client for accessing the Akismet REST API
Services_Akismet_HttpClient_Curl
cURL-based simple HTTP client for accessing the Akismet REST API

Inherited Variables

Inherited Methods


Class Details

[line 105]
Abstract simple HTTP client for accessing the Akismet REST API

This class contains a factory method for creating instances using a particular implementation. For example:

  1.  <?php
  2.  // creates a streams-based http client for use with the Akismet package
  3.  $client Services_Akismet_HttpClient::factory('streams',
  4.      'rest.akismet.com'80'Services_Akismet');
  5.  ?>

The available implementations are:

  • sockets (default)
  • streams
  • curl
This HTTP client only supports the HTTP POST method since that is all that is needed for the Akismet API.

Example usage:

  1.  // creates a streams-based http client for use with the Akismet package
  2.  $client Services_Akismet_HttpClient::factory('rest.akismet.com'80,
  3.      'Services_Akismet''streams');



[ Top ]


Method Detail

__construct (Constructor)   [line 193]

Services_Akismet_HttpClient __construct( string $host, integer $port, string $userAgent)

Creates a new HTTP client for accessing the Akismet REST API

Instances of this HTTP client must be instantiated using the Services_Akismet_HttpClient::factory() method.

  • Abstract:
  • Throws: PEAR_Exception if the implementation is not supported by the current PHP installation.
  • Access: protected

Overridden in child classes as:

Services_Akismet_HttpClient_Socket::__construct()
Creates a new TCP/IP socket-based HTTP client for accessing the Akismet REST API
Services_Akismet_HttpClient_Stream::__construct()
Creates a new streams-based HTTP client for accessing the Akismet REST API
Services_Akismet_HttpClient_Curl::__construct()
Creates a new cURL-based HTTP client for accessing the Akismet REST API

Parameters:

string   $host   —  the Akismet API server host name.
integer   $port   —  the TCP/IP connection port of this HTTP client.
string   $userAgent   —  the HTTP user agent of this HTTP client.

[ Top ]

factory   [line 128]

Services_Akismet_HttpClient factory( string $host, integer $port, string $userAgent, [string $implementation = 'sockets'])

Factory method to instantiate a HTTP client implementation
  • Return: the instantiated HTTP client implementation.
  • Throws: PEAR_Exception if the implementation is not supported by the current PHP installation or if the provided implementation does not exist.
  • Access: public

Parameters:

string   $host   —  the Akismet API server host name.
integer   $port   —  the TCP/IP connection port of the HTTP client.
string   $userAgent   —  the HTTP user agent of the HTTP client.
string   $implementation   —  optional. The name of the implementation to instantiate. Must be one of 'sockets', 'streams' or 'curl'. If not specified, defaults to 'sockets'.

[ Top ]

post   [line 174]

string post( string $path, string $content, [string $apiKey = ''])

Makes a HTTP POST request on the Akismet API server
  • Return: the content of the HTTP response from the Akismet API server.
  • Abstract:
  • Throws: Services_Akismet_CommunicationException if there is an error communicating with the Akismet API server.
  • Access: public

Overridden in child classes as:

Services_Akismet_HttpClient_Socket::post()
Makes a HTTP POST request on the Akismet API server
Services_Akismet_HttpClient_Stream::post()
Makes a HTTP POST request on the Akismet API server
Services_Akismet_HttpClient_Curl::post()
Makes a HTTP POST request on the Akismet API server

Parameters:

string   $path   —  the resource to post to.
string   $content   —  the data to post.
string   $apiKey   —  optional. The Wordpress API key to use for the request. If not specified, no API key information is included in the request. This is used for key validation.

[ Top ]


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