import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -18,17 +18,17 @@
* @subpackage Technorati
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Technorati.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Technorati.php 13522 2009-01-06 16:35:55Z thomas $
*/
/**
* Zend_Service_Technorati provides an easy, intuitive and object-oriented interface
* for using the Technorati API.
*
* It provides access to all available Technorati API queries
* Zend_Service_Technorati provides an easy, intuitive and object-oriented interface
* for using the Technorati API.
*
* It provides access to all available Technorati API queries
* and returns the original XML response as a friendly PHP object.
*
*
* @category Zend
* @package Zend_Service
* @subpackage Technorati
@ -39,7 +39,7 @@ class Zend_Service_Technorati
{
/** Base Technorati API URI */
const API_URI_BASE = 'http://api.technorati.com';
/** Query paths */
const API_PATH_COSMOS = '/cosmos';
const API_PATH_SEARCH = '/search';
@ -50,7 +50,7 @@ class Zend_Service_Technorati
const API_PATH_BLOGPOSTTAGS = '/blogposttags';
const API_PATH_GETINFO = '/getinfo';
const API_PATH_KEYINFO = '/keyinfo';
/** Prevent magic numbers */
const PARAM_LIMIT_MIN_VALUE = 1;
const PARAM_LIMIT_MAX_VALUE = 100;
@ -94,7 +94,7 @@ class Zend_Service_Technorati
/**
* Cosmos query lets you see what blogs are linking to a given URL.
*
*
* On the Technorati site, you can enter a URL in the searchbox and
* it will return a list of blogs linking to it.
* The API version allows more features and gives you a way
@ -131,7 +131,7 @@ class Zend_Service_Technorati
* highlights the citation of the given URL within the weblog excerpt.
* Set this parameter to FALSE to apply no special markup to the blog excerpt.
* Internally the value is converted in (int).
*
*
* @param string $url the URL you are searching for. Prefixes http:// and www. are optional.
* @param array $options additional parameters to refine your query
* @return Zend_Service_Technorati_CosmosResultSet
@ -156,8 +156,8 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_COSMOS, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
* @see Zend_Service_Technorati_CosmosResultSet
/**
* @see Zend_Service_Technorati_CosmosResultSet
*/
require_once 'Zend/Service/Technorati/CosmosResultSet.php';
return new Zend_Service_Technorati_CosmosResultSet($dom, $options);
@ -169,14 +169,14 @@ class Zend_Service_Technorati
* Query options include:
*
* 'language' => (string)
* optional - a ISO 639-1 two character language code
* to retrieve results specific to that language.
* optional - a ISO 639-1 two character language code
* to retrieve results specific to that language.
* This feature is currently beta and may not work for all languages.
* 'authority' => (n|a1|a4|a7)
* optional - filter results to those from blogs with at least
* the Technorati Authority specified.
* Technorati calculates a blog's authority by how many people link to it.
* Filtering by authority is a good way to refine your search results.
* optional - filter results to those from blogs with at least
* the Technorati Authority specified.
* Technorati calculates a blog's authority by how many people link to it.
* Filtering by authority is a good way to refine your search results.
* There are four settings:
* - n => Any authority: All results.
* - a1 => A little authority: Results from blogs with at least one link.
@ -197,7 +197,7 @@ class Zend_Service_Technorati
* in the result set when a weblog in your result set
* has been successfully claimed by a member of Technorati.
* Internally the value is converted in (int).
*
*
* @param string $query the words you are searching for.
* @param array $options additional parameters to refine your query
* @return Zend_Service_Technorati_SearchResultSet
@ -218,7 +218,7 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_SEARCH, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_SearchResultSet
*/
require_once 'Zend/Service/Technorati/SearchResultSet.php';
@ -229,7 +229,7 @@ class Zend_Service_Technorati
* Tag lets you see what posts are associated with a given tag.
*
* Query options include:
*
*
* 'limit' => (int)
* optional - adjust the size of your result from the default value of 20
* to between 1 and 100 results.
@ -239,12 +239,12 @@ class Zend_Service_Technorati
* the portion of Technorati's total result set ranging from start to start+limit.
* The default start value is 1.
* 'excerptsize' => (int)
* optional - number of word characters to include in the post excerpts.
* optional - number of word characters to include in the post excerpts.
* By default 100 word characters are returned.
* 'topexcerptsize' => (int)
* optional - number of word characters to include in the first post excerpt.
* optional - number of word characters to include in the first post excerpt.
* By default 150 word characters are returned.
*
*
* @param string $tag the tag term you are searching posts for.
* @param array $options additional parameters to refine your query
* @return Zend_Service_Technorati_TagResultSet
@ -266,7 +266,7 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_TAG, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_TagResultSet
*/
require_once 'Zend/Service/Technorati/TagResultSet.php';
@ -279,10 +279,10 @@ class Zend_Service_Technorati
* Query options include:
*
* 'days' => (int)
* optional - Used to specify the number of days in the past
* to request daily count data for.
* optional - Used to specify the number of days in the past
* to request daily count data for.
* Can be any integer between 1 and 180, default is 180
*
*
* @param string $q the keyword query
* @param array $options additional parameters to refine your query
* @return Zend_Service_Technorati_DailyCountsResultSet
@ -302,13 +302,13 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_DAILYCOUNTS, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_DailyCountsResultSet
*/
require_once 'Zend/Service/Technorati/DailyCountsResultSet.php';
return new Zend_Service_Technorati_DailyCountsResultSet($dom);
}
/**
* TopTags provides information on top tags indexed by Technorati.
*
@ -322,7 +322,7 @@ class Zend_Service_Technorati
* Set this number to larger than zero and you will receive
* the portion of Technorati's total result set ranging from start to start+limit.
* The default start value is 1.
*
*
* @param array $options additional parameters to refine your query
* @return Zend_Service_Technorati_TagsResultSet
* @throws Zend_Service_Technorati_Exception
@ -340,7 +340,7 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_TOPTAGS, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_TagsResultSet
*/
require_once 'Zend/Service/Technorati/TagsResultSet.php';
@ -369,13 +369,13 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_BLOGINFO, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_BlogInfoResult
*/
require_once 'Zend/Service/Technorati/BlogInfoResult.php';
return new Zend_Service_Technorati_BlogInfoResult($dom);
}
/**
* BlogPostTags provides information on the top tags used by a specific blog.
*
@ -390,7 +390,7 @@ class Zend_Service_Technorati
* the portion of Technorati's total result set ranging from start to start+limit.
* The default start value is 1.
* Note. This property is not documented.
*
*
* @param string $url the URL you are searching for. Prefixes http:// and www. are optional.
* The URL must be recognized by Technorati as a blog.
* @param array $options additional parameters to refine your query
@ -412,21 +412,21 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_BLOGPOSTTAGS, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_TagsResultSet
*/
require_once 'Zend/Service/Technorati/TagsResultSet.php';
return new Zend_Service_Technorati_TagsResultSet($dom);
}
/**
* GetInfo query tells you things that Technorati knows about a member.
*
* The returned info is broken up into two sections:
* The first part describes some information that the user wants
* to allow people to know about him- or herself.
* The second part of the document is a listing of the weblogs
* that the user has successfully claimed and the information
*
* The returned info is broken up into two sections:
* The first part describes some information that the user wants
* to allow people to know about him- or herself.
* The second part of the document is a listing of the weblogs
* that the user has successfully claimed and the information
* that Technorati knows about these weblogs.
*
* @param string $username the Technorati user name you are searching for
@ -435,7 +435,7 @@ class Zend_Service_Technorati
* @throws Zend_Service_Technorati_Exception
* @link http://technorati.com/developers/api/getinfo.html Technorati API: GetInfo reference
*/
public function getInfo($username, $options = null)
public function getInfo($username, $options = null)
{
static $defaultOptions = array('format' => 'xml');
@ -446,19 +446,19 @@ class Zend_Service_Technorati
$response = $this->_makeRequest(self::API_PATH_GETINFO, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_GetInfoResult
*/
require_once 'Zend/Service/Technorati/GetInfoResult.php';
return new Zend_Service_Technorati_GetInfoResult($dom);
}
/**
* KeyInfo query provides information on daily usage of an API key.
* KeyInfo query provides information on daily usage of an API key.
* Key Info Queries do not count against a key's daily query limit.
*
*
* A day is defined as 00:00-23:59 Pacific time.
*
*
* @return Zend_Service_Technorati_KeyInfoResult
* @throws Zend_Service_Technorati_Exception
* @link http://developers.technorati.com/wiki/KeyInfo Technorati API: Key Info reference
@ -469,15 +469,15 @@ class Zend_Service_Technorati
$options = $this->_prepareOptions(array(), $defaultOptions);
// you don't need to validate this request
// because key is the only mandatory element
// because key is the only mandatory element
// and it's already set in #_prepareOptions
$response = $this->_makeRequest(self::API_PATH_KEYINFO, $options);
$dom = $this->_convertResponseAndCheckContent($response);
/**
/**
* @see Zend_Service_Technorati_KeyInfoResult
*/
require_once 'Zend/Service/Technorati/KeyInfoResult.php';
require_once 'Zend/Service/Technorati/KeyInfoResult.php';
return new Zend_Service_Technorati_KeyInfoResult($dom, $this->_apiKey);
}
@ -502,7 +502,7 @@ class Zend_Service_Technorati
*/
public function getRestClient()
{
if (is_null($this->_restClient)) {
if ($this->_restClient === null) {
/**
* @see Zend_Rest_Client
*/
@ -515,7 +515,7 @@ class Zend_Service_Technorati
/**
* Sets Technorati API key.
*
*
* Be aware that this function doesn't validate the key.
* The key is validated as soon as the first API request is sent.
* If the key is invalid, the API request method will throw
@ -568,7 +568,7 @@ class Zend_Service_Technorati
}
}
/**
* Validates Search query options.
*
@ -597,7 +597,7 @@ class Zend_Service_Technorati
// Validate format (optional)
$this->_validateOptionFormat($options);
}
/**
* Validates Tag query options.
*
@ -627,7 +627,7 @@ class Zend_Service_Technorati
$this->_validateOptionFormat($options);
}
/**
* Validates DailyCounts query options.
*
@ -650,7 +650,7 @@ class Zend_Service_Technorati
// Validate days (optional)
if (isset($options['days'])) {
$options['days'] = (int) $options['days'];
if ($options['days'] < self::PARAM_DAYS_MIN_VALUE ||
if ($options['days'] < self::PARAM_DAYS_MIN_VALUE ||
$options['days'] > self::PARAM_DAYS_MAX_VALUE) {
/**
* @see Zend_Service_Technorati_Exception
@ -661,7 +661,7 @@ class Zend_Service_Technorati
}
}
}
/**
* Validates GetInfo query options.
*
@ -693,7 +693,7 @@ class Zend_Service_Technorati
*/
protected function _validateTopTags(array $options)
{
static $validOptions = array('key',
static $validOptions = array('key',
'limit', 'start', 'format');
// Validate keys in the $options array
@ -705,7 +705,7 @@ class Zend_Service_Technorati
// Validate format (optional)
$this->_validateOptionFormat($options);
}
/**
* Validates BlogInfo query options.
*
@ -726,7 +726,7 @@ class Zend_Service_Technorati
// Validate format (optional)
$this->_validateOptionFormat($options);
}
/**
* Validates TopTags query options.
*
@ -737,7 +737,7 @@ class Zend_Service_Technorati
*/
protected function _validateBlogPostTags(array $options)
{
static $validOptions = array('key', 'url',
static $validOptions = array('key', 'url',
'limit', 'start', 'format');
// Validate keys in the $options array
@ -773,16 +773,16 @@ class Zend_Service_Technorati
"Invalid value '{$options[$name]}' for '$name' option");
}
}
/**
* Checks whether mandatory $name option exists and it's valid.
*
*
* @param array $options
* @return void
* @throws Zend_Service_Technorati_Exception
* @access protected
*/
protected function _validateMandatoryOption($name, $options)
protected function _validateMandatoryOption($name, $options)
{
if (!isset($options[$name]) || !trim($options[$name])) {
/**
@ -793,25 +793,25 @@ class Zend_Service_Technorati
"Empty value for '$name' option");
}
}
/**
* Checks whether $name option is a valid integer and casts it.
*
*
* @param array $options
* @return void
* @access protected
*/
protected function _validateIntegerOption($name, $options)
protected function _validateIntegerOption($name, $options)
{
if (isset($options[$name])) {
$options[$name] = (int) $options[$name];
}
}
/**
* Makes and HTTP GET request to given $path with $options.
* HTTP Response is first validated, then returned.
*
*
* @param string $path
* @param array $options
* @return Zend_Http_Response
@ -828,27 +828,27 @@ class Zend_Service_Technorati
}
/**
* Checks whether 'claim' option value is valid.
*
* Checks whether 'claim' option value is valid.
*
* @param array $options
* @return void
* @access protected
*/
protected function _validateOptionClaim(array $options)
protected function _validateOptionClaim(array $options)
{
$this->_validateIntegerOption('claim', $options);
}
/**
* Checks whether 'format' option value is valid.
* Checks whether 'format' option value is valid.
* Be aware that Zend_Service_Technorati supports only XML as format value.
*
*
* @param array $options
* @return void
* @throws Zend_Service_Technorati_Exception if 'format' value != XML
* @access protected
*/
protected function _validateOptionFormat(array $options)
protected function _validateOptionFormat(array $options)
{
if (isset($options['format']) && $options['format'] != 'xml') {
/**
@ -860,23 +860,23 @@ class Zend_Service_Technorati
"Zend_Service_Technorati supports only 'xml'");
}
}
/**
* Checks whether 'limit' option value is valid.
* Checks whether 'limit' option value is valid.
* Value must be an integer greater than PARAM_LIMIT_MIN_VALUE
* and lower than PARAM_LIMIT_MAX_VALUE.
*
*
* @param array $options
* @return void
* @throws Zend_Service_Technorati_Exception if 'limit' value is invalid
* @access protected
*/
protected function _validateOptionLimit(array $options)
protected function _validateOptionLimit(array $options)
{
if (!isset($options['limit'])) return;
$options['limit'] = (int) $options['limit'];
if ($options['limit'] < self::PARAM_LIMIT_MIN_VALUE ||
if ($options['limit'] < self::PARAM_LIMIT_MIN_VALUE ||
$options['limit'] > self::PARAM_LIMIT_MAX_VALUE) {
/**
* @see Zend_Service_Technorati_Exception
@ -886,20 +886,20 @@ class Zend_Service_Technorati
"Invalid value '" . $options['limit'] . "' for 'limit' option");
}
}
/**
* Checks whether 'start' option value is valid.
* Checks whether 'start' option value is valid.
* Value must be an integer greater than 0.
*
*
* @param array $options
* @return void
* @throws Zend_Service_Technorati_Exception if 'start' value is invalid
* @access protected
*/
protected function _validateOptionStart(array $options)
protected function _validateOptionStart(array $options)
{
if (!isset($options['start'])) return;
$options['start'] = (int) $options['start'];
if ($options['start'] < self::PARAM_START_MIN_VALUE) {
/**
@ -912,20 +912,20 @@ class Zend_Service_Technorati
}
/**
* Checks whether 'url' option value exists and is valid.
* Checks whether 'url' option value exists and is valid.
* 'url' must be a valid HTTP(s) URL.
*
*
* @param array $options
* @return void
* @throws Zend_Service_Technorati_Exception if 'url' value is invalid
* @access protected
* @todo support for Zend_Uri_Http
*/
protected function _validateOptionUrl(array $options)
protected function _validateOptionUrl(array $options)
{
$this->_validateMandatoryOption('url', $options);
}
/**
* Checks XML response content for errors.
*
@ -952,7 +952,7 @@ class Zend_Service_Technorati
/**
* Converts $response body to a DOM object and checks it.
*
*
* @param Zend_Http_Response $response
* @return DOMDocument
* @throws Zend_Service_Technorati_Exception if response content contains an error message
@ -965,7 +965,7 @@ class Zend_Service_Technorati
self::_checkErrors($dom);
return $dom;
}
/**
* Checks ReST response for errors.
*
@ -989,7 +989,7 @@ class Zend_Service_Technorati
/**
* Checks whether user given options are valid.
*
*
* @param array $options user options
* @param array $validOptions valid options
* @return void
@ -1005,7 +1005,7 @@ class Zend_Service_Technorati
*/
require_once 'Zend/Service/Technorati/Exception.php';
throw new Zend_Service_Technorati_Exception(
"The following parameters are invalid: '" .
"The following parameters are invalid: '" .
implode("', '", $difference) . "'");
}
}