Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Feed_Pubsubhubbub_Subscriber Class Reference

Public Member Functions

 __construct ($config=null)
 Constructor; accepts an array or Zend_Config instance to preset options for the Subscriber without calling all supported setter methods in turn.
 
 setConfig ($config)
 Process any injected configuration options.
 
 setTopicUrl ($url)
 Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.
 
 getTopicUrl ()
 Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.
 
 setLeaseSeconds ($seconds)
 Set the number of seconds for which any subscription will remain valid.
 
 getLeaseSeconds ()
 Get the number of lease seconds on subscriptions.
 
 setCallbackUrl ($url)
 Set the callback URL to be used by Hub Servers when communicating with this Subscriber.
 
 getCallbackUrl ()
 Get the callback URL to be used by Hub Servers when communicating with this Subscriber.
 
 setPreferredVerificationMode ($mode)
 Set preferred verification mode (sync or async).
 
 getPreferredVerificationMode ()
 Get preferred verification mode (sync or async).
 
 addHubUrl ($url)
 Add a Hub Server URL supported by Publisher.
 
 addHubUrls (array $urls)
 Add an array of Hub Server URLs supported by Publisher.
 
 removeHubUrl ($url)
 Remove a Hub Server URL.
 
 getHubUrls ()
 Return an array of unique Hub Server URLs currently available.
 
 addAuthentication ($url, array $authentication)
 Add authentication credentials for a given URL.
 
 addAuthentications (array $authentications)
 Add authentication credentials for hub URLs.
 
 getAuthentications ()
 Get all hub URL authentication credentials.
 
 usePathParameter ($bool=true)
 Set flag indicating whether or not to use a path parameter.
 
 setParameter ($name, $value=null)
 Add an optional parameter to the (un)subscribe requests.
 
 setParameters (array $parameters)
 Add an optional parameter to the (un)subscribe requests.
 
 removeParameter ($name)
 Remove an optional parameter for the (un)subscribe requests.
 
 getParameters ()
 Return an array of optional parameters for (un)subscribe requests.
 
 setStorage (Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage)
 Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background save any verification tokens associated with a subscription or other.
 
 getStorage ()
 Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used to background save any verification tokens associated with a subscription or other.
 
 subscribeAll ()
 Subscribe to one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)
 
 unsubscribeAll ()
 Unsubscribe from one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)
 
 isSuccess ()
 Returns a boolean indicator of whether the notifications to Hub Servers were ALL successful.
 
 getErrors ()
 Return an array of errors met from any failures, including keys: 'response' => the Zend_Http_Response object from the failure 'hubUrl' => the URL of the Hub Server whose notification failed.
 
 getAsyncHubs ()
 Return an array of Hub Server URLs who returned a response indicating operation in Asynchronous Verification Mode, i.e.
 
 setTestStaticToken ($token)
 

Protected Member Functions

 _doRequest ($mode)
 Executes an (un)subscribe request.
 
 _getHttpClient ()
 Get a basic prepared HTTP client for use.
 
 _getRequestParameters ($hubUrl, $mode)
 Return a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL.
 
 _generateVerifyToken ()
 Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.
 
 _generateSubscriptionKey (array $params, $hubUrl)
 Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.
 
 _urlEncode (array $params)
 URL Encode an array of parameters.
 
 _toByteValueOrderedString (array $params)
 Order outgoing parameters.
 

Protected Attributes

 $_hubUrls = array()
 
 $_parameters = array()
 
 $_topicUrl = ''
 
 $_callbackUrl = ''
 
 $_leaseSeconds = null
 
 $_preferredVerificationMode = Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC
 
 $_errors = array()
 
 $_asyncHubs = array()
 
 $_storage = null
 
 $_authentications = array()
 
 $_usePathParameter = false
 
 $_testStaticToken = null
 This is STRICTLY for testing purposes only...
 

Constructor & Destructor Documentation

__construct (   $config = null)

Constructor; accepts an array or Zend_Config instance to preset options for the Subscriber without calling all supported setter methods in turn.

Parameters
array | Zend_Config$optionsOptions array or Zend_Config instance
Returns
void

Member Function Documentation

_doRequest (   $mode)
protected

Executes an (un)subscribe request.

Parameters
string$mode
Returns
void

At first I thought it was needed, but the backend storage will allow tracking async without any user interference. It's left here in case the user is interested in knowing what Hubs are using async verification modes so they may update Models and move these to asynchronous processes.

_generateSubscriptionKey ( array  $params,
  $hubUrl 
)
protected

Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.

Parameters
string$hubUrlThe Hub Server URL for which this token will apply
Returns
string
_generateVerifyToken ( )
protected

Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.

Follows no particular method, which means it might be improved/changed in future.

Parameters
string$hubUrlThe Hub Server URL for which this token will apply
Returns
string
_getHttpClient ( )
protected

Get a basic prepared HTTP client for use.

Parameters
string$modeMust be "subscribe" or "unsubscribe"
Returns
Zend_Http_Client
_getRequestParameters (   $hubUrl,
  $mode 
)
protected

Return a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL.

Parameters
string$hubUrl
mode$hubUrl
Returns
string

Establish a persistent verify_token and attach key to callback URL's path/querystring

_toByteValueOrderedString ( array  $params)
protected

Order outgoing parameters.

Parameters
array$params
Returns
array
_urlEncode ( array  $params)
protected

URL Encode an array of parameters.

Parameters
array$params
Returns
array
addAuthentication (   $url,
array  $authentication 
)

Add authentication credentials for a given URL.

Parameters
string$url
array$authentication
Returns
Zend_Feed_Pubsubhubbub_Subscriber
addAuthentications ( array  $authentications)

Add authentication credentials for hub URLs.

Parameters
array$authentications
Returns
Zend_Feed_Pubsubhubbub_Subscriber
addHubUrl (   $url)

Add a Hub Server URL supported by Publisher.

Parameters
string$url
Returns
Zend_Feed_Pubsubhubbub_Subscriber
addHubUrls ( array  $urls)

Add an array of Hub Server URLs supported by Publisher.

Parameters
array$urls
Returns
Zend_Feed_Pubsubhubbub_Subscriber
getAsyncHubs ( )

Return an array of Hub Server URLs who returned a response indicating operation in Asynchronous Verification Mode, i.e.

they will not confirm any (un)subscription immediately but at a later time (Hubs may be doing this as a batch process when load balancing)

Returns
array
getAuthentications ( )

Get all hub URL authentication credentials.

Returns
array
getCallbackUrl ( )

Get the callback URL to be used by Hub Servers when communicating with this Subscriber.

Returns
string
getErrors ( )

Return an array of errors met from any failures, including keys: 'response' => the Zend_Http_Response object from the failure 'hubUrl' => the URL of the Hub Server whose notification failed.

Returns
array
getHubUrls ( )

Return an array of unique Hub Server URLs currently available.

Returns
array
getLeaseSeconds ( )

Get the number of lease seconds on subscriptions.

Returns
int
getParameters ( )

Return an array of optional parameters for (un)subscribe requests.

Returns
array
getPreferredVerificationMode ( )

Get preferred verification mode (sync or async).

Returns
string
getStorage ( )

Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used to background save any verification tokens associated with a subscription or other.

Returns
Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
getTopicUrl ( )

Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.

Returns
string
isSuccess ( )

Returns a boolean indicator of whether the notifications to Hub Servers were ALL successful.

If even one failed, FALSE is returned.

Returns
bool
removeHubUrl (   $url)

Remove a Hub Server URL.

Parameters
string$url
Returns
Zend_Feed_Pubsubhubbub_Subscriber
removeParameter (   $name)

Remove an optional parameter for the (un)subscribe requests.

Parameters
string$name
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setCallbackUrl (   $url)

Set the callback URL to be used by Hub Servers when communicating with this Subscriber.

Parameters
string$url
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setConfig (   $config)

Process any injected configuration options.

Parameters
array | Zend_Config$optionsOptions array or Zend_Config instance
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setLeaseSeconds (   $seconds)

Set the number of seconds for which any subscription will remain valid.

Parameters
int$seconds
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setParameter (   $name,
  $value = null 
)

Add an optional parameter to the (un)subscribe requests.

Parameters
string$name
string | null$value
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setParameters ( array  $parameters)

Add an optional parameter to the (un)subscribe requests.

Parameters
string$name
string | null$value
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setPreferredVerificationMode (   $mode)

Set preferred verification mode (sync or async).

By default, this Subscriber prefers synchronous verification, but does support asynchronous if that's the Hub Server's utilised mode.

Zend_Feed_Pubsubhubbub_Subscriber will always send both modes, whose order of occurance in the parameter list determines this preference.

Parameters
string$modeShould be 'sync' or 'async'
Returns
Zend_Feed_Pubsubhubbub_Subscriber

Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background save any verification tokens associated with a subscription or other.

Parameters
Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface$storage
Returns
Zend_Feed_Pubsubhubbub_Subscriber
setTestStaticToken (   $token)
final
setTopicUrl (   $url)

Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.

Parameters
string$url
Returns
Zend_Feed_Pubsubhubbub_Subscriber
subscribeAll ( )

Subscribe to one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)

Returns
void
unsubscribeAll ( )

Unsubscribe from one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)

Returns
void
usePathParameter (   $bool = true)

Set flag indicating whether or not to use a path parameter.

Parameters
bool$bool
Returns
Zend_Feed_Pubsubhubbub_Subscriber

Member Data Documentation

$_asyncHubs = array()
protected
$_authentications = array()
protected
$_callbackUrl = ''
protected
$_errors = array()
protected
$_hubUrls = array()
protected
$_leaseSeconds = null
protected
$_parameters = array()
protected
$_preferredVerificationMode = Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC
protected
$_storage = null
protected
$_testStaticToken = null
protected

This is STRICTLY for testing purposes only...

$_topicUrl = ''
protected
$_usePathParameter = false
protected