Feed/Pubsubhubbub/Subscriber.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Feed_Pubsubhubbub
- Version
- $Id: Subscriber.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Feed_Pubsubhubbub_Subscriber
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties

array $_asyncHubs = array()An array of Hub Server URLs for Hubs operating at this time in asynchronous verification mode.
array()Details- Type
- array

array $_authentications = array()An array of authentication credentials for HTTP Basic Authentication if required by specific Hubs.
The array is indexed by Hub Endpoint URI and the value is a simple array of the username and password to apply.
array()Details- Type
- array

string $_callbackUrl = ''The URL Hub Servers must use when communicating with this Subscriber
''Details- Type
- string

array $_errors = array()An array of any errors including keys for 'response', 'hubUrl'.
The response is the actual Zend_Http_Response object.
array()Details- Type
- array

array $_hubUrls = array()An array of URLs for all Hub Servers to subscribe/unsubscribe.
array()Details- Type
- array

int $_leaseSeconds = nullThe number of seconds for which the subscriber would like to have the subscription active.
Defaults to null, i.e. not sent, to setup a permanent subscription if possible.
nullDetails- Type
- int

array $_parameters = array()An array of optional parameters to be included in any (un)subscribe requests.
array()Details- Type
- array

string $_preferredVerificationMode = \Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNCThe preferred verification mode (sync or async).
By default, this Subscriber prefers synchronous verification, but is considered desireable to support asynchronous verification if possible.
Zend_Feed_Pubsubhubbub_Subscriber will always send both modes, whose order of occurance in the parameter list determines this preference.
\Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNCDetails- Type
- string

\Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $_storage = nullAn instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background save any verification tokens associated with a subscription or other.
nullDetails

$_testStaticToken = nullThis is STRICTLY for testing purposes only.
..
nullDetails- Type
- n/a

string $_topicUrl = ''The URL of the topic (Rss or Atom feed) which is the subject of our current intent to subscribe to/unsubscribe from updates from the currently configured Hub Servers.
''Details- Type
- string

string $_usePathParameter = falseTells the Subscriber to append any subscription identifier to the path of the base Callback URL.
E.g. an identifier "subkey1" would be added to the callback URL "http://www.example.com/callback" to create a subscription specific Callback URL of "http://www.example.com/callback/subkey1".
This is required for all Hubs using the Pubsubhubbub 0.1 Specification. It should be manually intercepted and passed to the Callback class using Zend_Feed_Pubsubhubbub_Subscriber_Callback::setSubscriptionKey(). Will require a route in the form "callback/:subkey" to allow the parameter be retrieved from an action using the Zend_Controller_Action::_getParam() method.
falseDetails- Type
- string
Methods

__construct( $config = null) : voidConstructor; accepts an array or Zend_Config instance to preset options for the Subscriber without calling all supported setter methods in turn.
| Name | Type | Description |
|---|---|---|
| $config |

_doRequest(string $mode) : voidExecutes an (un)subscribe request
| Name | Type | Description |
|---|---|---|
| $mode | string |

_generateSubscriptionKey( $params, string $hubUrl) : stringSimple helper to generate a verification token used in (un)subscribe requests to a Hub Server.
| Name | Type | Description |
|---|---|---|
| $params | ||
| $hubUrl | string | The Hub Server URL for which this token will apply |
| Type | Description |
|---|---|
| string |

_generateVerifyToken() : stringSimple 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.
| Type | Description |
|---|---|
| string |

_getHttpClient() : \Zend_Http_ClientGet a basic prepared HTTP client for use
| Type | Description |
|---|---|
| \Zend_Http_Client |

_getRequestParameters(string | \mode $hubUrl, $mode) : stringReturn a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL
| Name | Type | Description |
|---|---|---|
| $hubUrl | string | \mode | |
| $mode |
| Type | Description |
|---|---|
| string |

_toByteValueOrderedString(array $params) : arrayOrder outgoing parameters
| Name | Type | Description |
|---|---|---|
| $params | array |
| Type | Description |
|---|---|
| array |

_urlEncode(array $params) : arrayURL Encode an array of parameters
| Name | Type | Description |
|---|---|---|
| $params | array |
| Type | Description |
|---|---|
| array |

addAuthentication(string $url, array $authentication) : \Zend_Feed_Pubsubhubbub_SubscriberAdd authentication credentials for a given URL
| Name | Type | Description |
|---|---|---|
| $url | string | |
| $authentication | array |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

addAuthentications(array $authentications) : \Zend_Feed_Pubsubhubbub_SubscriberAdd authentication credentials for hub URLs
| Name | Type | Description |
|---|---|---|
| $authentications | array |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

addHubUrl(string $url) : \Zend_Feed_Pubsubhubbub_SubscriberAdd a Hub Server URL supported by Publisher
| Name | Type | Description |
|---|---|---|
| $url | string |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

addHubUrls(array $urls) : \Zend_Feed_Pubsubhubbub_SubscriberAdd an array of Hub Server URLs supported by Publisher
| Name | Type | Description |
|---|---|---|
| $urls | array |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

getAsyncHubs() : arrayReturn 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)
| Type | Description |
|---|---|
| array |

getAuthentications() : arrayGet all hub URL authentication credentials
| Type | Description |
|---|---|
| array |

getCallbackUrl() : stringGet the callback URL to be used by Hub Servers when communicating with this Subscriber
| Type | Description |
|---|---|
| string |

getErrors() : arrayReturn 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
| Type | Description |
|---|---|
| array |

getHubUrls() : arrayReturn an array of unique Hub Server URLs currently available
| Type | Description |
|---|---|
| array |

getLeaseSeconds() : intGet the number of lease seconds on subscriptions
| Type | Description |
|---|---|
| int |

getParameters() : arrayReturn an array of optional parameters for (un)subscribe requests
| Type | Description |
|---|---|
| array |

getPreferredVerificationMode() : stringGet preferred verification mode (sync or async).
| Type | Description |
|---|---|
| string |

getStorage() : \Zend_Feed_Pubsubhubbub_Model_SubscriptionInterfaceGets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used to background save any verification tokens associated with a subscription or other.
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface |

getTopicUrl() : stringSet the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate
| Type | Description |
|---|---|
| string |

isSuccess() : boolReturns a boolean indicator of whether the notifications to Hub Servers were ALL successful.
If even one failed, FALSE is returned.
| Type | Description |
|---|---|
| bool |

removeHubUrl(string $url) : \Zend_Feed_Pubsubhubbub_SubscriberRemove a Hub Server URL
| Name | Type | Description |
|---|---|---|
| $url | string |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

removeParameter(string $name) : \Zend_Feed_Pubsubhubbub_SubscriberRemove an optional parameter for the (un)subscribe requests
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setCallbackUrl(string $url) : \Zend_Feed_Pubsubhubbub_SubscriberSet the callback URL to be used by Hub Servers when communicating with this Subscriber
| Name | Type | Description |
|---|---|---|
| $url | string |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setConfig( $config) : \Zend_Feed_Pubsubhubbub_SubscriberProcess any injected configuration options
| Name | Type | Description |
|---|---|---|
| $config |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setLeaseSeconds(int $seconds) : \Zend_Feed_Pubsubhubbub_SubscriberSet the number of seconds for which any subscription will remain valid
| Name | Type | Description |
|---|---|---|
| $seconds | int |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setParameter(string $name, string | null $value = null) : \Zend_Feed_Pubsubhubbub_SubscriberAdd an optional parameter to the (un)subscribe requests
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string | null |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setParameters( $parameters) : \Zend_Feed_Pubsubhubbub_SubscriberAdd an optional parameter to the (un)subscribe requests
| Name | Type | Description |
|---|---|---|
| $parameters |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setPreferredVerificationMode(string $mode) : \Zend_Feed_Pubsubhubbub_SubscriberSet 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.
| Name | Type | Description |
|---|---|---|
| $mode | string | Should be 'sync' or 'async' |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setStorage(\Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage) : \Zend_Feed_Pubsubhubbub_SubscriberSets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background save any verification tokens associated with a subscription or other.
| Name | Type | Description |
|---|---|---|
| $storage | \Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

setTopicUrl(string $url) : \Zend_Feed_Pubsubhubbub_SubscriberSet the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate
| Name | Type | Description |
|---|---|---|
| $url | string |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |

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

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

usePathParameter(bool $bool = true) : \Zend_Feed_Pubsubhubbub_SubscriberSet flag indicating whether or not to use a path parameter
| Name | Type | Description |
|---|---|---|
| $bool | bool |
| Type | Description |
|---|---|
| \Zend_Feed_Pubsubhubbub_Subscriber |