ZendService\Technorati

ZendService\Technorati\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.

Technorati is one of the most popular blog search engines. The API interface enables developers to retrieve
information about a specific blog, search blogs matching a single tag or phrase and get information about a
specific author (blogger). For a full list of available queries please see the Technorati API documentation or
the Available Technorati queries section of this document.

In order to run a query, first you need a ZendService\Technorati\Technorati instance with a valid API key. Then choose
one of the available query methods, and call it providing required arguments.

Sending your first query

1
2
3
4
5
6

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// search Technorati for PHP keyword$resultSet=$technorati->search('PHP');

Each query method accepts an array of optional parameters that can be used to refine your query.

Refining your query

1
2
3
4
5
6
7
8
9
10

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// filter your query including only results// with some authority (Results from blogs with a handful of links)$options=array('authority'=>'a4');// search Technorati for PHP keyword$resultSet=$technorati->search('PHP',$options);

A ZendService\Technorati\Technorati instance is not a single-use object. That is, you don’t need to create a new instance
for each query call; simply use your current ZendService\Technorati\Technorati object as long as you need it.

Sending multiple queries with the same ZendServiceTechnoratiTechnorati instance

1
2
3
4
5
6
7
8
9

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// search Technorati for PHP keyword$search=$technorati->search('PHP');// get top tags indexed by Technorati$topTags=$technorati->topTags();

The first group is represented by ZendService\Technorati\*ResultSet objects. A result set object is basically
a collection of result objects. It extends the basic ZendService\Technorati\ResultSet class and implements the
SeekableIteratorPHP interface. The best way to consume a result set object is to loop over it with the PHPforeach() statement.

Consuming a result set object

1
2
3
4
5
6
7
8
9
10
11
12

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// search Technorati for PHP keyword// $resultSet is an instance of ZendService\Technorati\SearchResultSet$resultSet=$technorati->search('PHP');// loop over all result objectsforeach($resultSetas$result){// $result is an instance of ZendService\Technorati\SearchResult}

Because ZendService\Technorati\ResultSet implements the SeekableIterator interface, you can seek a
specific result object using its position in the result collection.

Seeking a specific result set object

1
2
3
4
5
6
7
8
9
10
11

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// search Technorati for PHP keyword// $resultSet is an instance of ZendService\Technorati\SearchResultSet$resultSet=$technorati->search('PHP');// $result is an instance of ZendService\Technorati\SearchResult$resultSet->seek(1);$result=$resultSet->current();

Note

SeekableIterator works as an array and counts positions starting from index 0. Fetching position number 1
means getting the second result in the collection.

The second group is represented by special standalone result objects. ZendService\Technorati\GetInfoResult,
ZendService\Technorati\BlogInfoResult and ZendService\Technorati\KeyInfoResult act as wrappers for
additional objects, such as ZendService\Technorati\Author and ZendService\Technorati\Weblog.

Consuming a standalone result object

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

// create a new ZendService\Technorati\Technorati// with a valid API_KEY$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');// get info about weppos author$result=$technorati->getInfo('weppos');$author=$result->getAuthor();echo'<h2>Blogs authored by '.$author->getFirstName()." ".$author->getLastName().'</h2>';echo'<ol>';foreach($result->getWeblogs()as$weblog){echo'<li>'.$weblog->getName().'</li>';}echo"</ol>";

Each ZendService\Technorati\Technorati query method throws a ZendService\Technorati\Exception exception on failure
with a meaningful error message.

There are several reasons that may cause a ZendService\Technorati\Technorati query to fail. ZendService\Technorati\Technorati
validates all parameters for any query request. If a parameter is invalid or it contains an invalid value, a new
ZendService\Technorati\Exception exception is thrown. Additionally, the Technorati API interface could be
temporally unavailable, or it could return a response that is not well formed.

From time to time you probably will want to check your API key daily usage. By default Technorati limits your
API usage to 500 calls per day, and an exception is returned by ZendService\Technorati\Technorati if you try to use it
beyond this limit. You can get information about your API key usage using the
ZendService\Technorati\Technorati::keyInfo() method.

ZendService\Technorati\Technorati::keyInfo() returns a ZendService\Technorati\KeyInfoResult object. For full details
please see the API reference guide.

$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');$resultSet=$technorati->cosmos('http://devzone.zend.com/');echo"<p>Reading ".$resultSet->totalResults()." of ".$resultSet->totalResultsAvailable()." available results</p>";echo"<ol>";foreach($resultSetas$result){echo"<li>".$result->getWeblog()->getName()."</li>";}echo"</ol>";

$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');$resultSet=$technorati->tag('php');echo"<p>Reading ".$resultSet->totalResults()." of ".$resultSet->totalResultsAvailable()." available results</p>";echo"<ol>";foreach($resultSetas$result){echo"<li>".$result->getWeblog()->getName()."</li>";}echo"</ol>";

$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');$resultSet=$technorati->topTags();echo"<p>Reading ".$resultSet->totalResults()." of ".$resultSet->totalResultsAvailable()." available results</p>";echo"<ol>";foreach($resultSetas$result){echo"<li>".$result->getTag()."</li>";}echo"</ol>";

$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');$resultSet=$technorati->blogPostTags('http://devzone.zend.com/');echo"<p>Reading ".$resultSet->totalResults()." of ".$resultSet->totalResultsAvailable()." available results</p>";echo"<ol>";foreach($resultSetas$result){echo"<li>".$result->getTag()."</li>";}echo"</ol>";

The following classes are returned by the various Technorati queries. Each ZendService\Technorati\*ResultSet
class holds a type-specific result set which can be easily iterated, with each result being contained in a type
result object. All result set classes extend ZendService\Technorati\ResultSet class and implement the
SeekableIterator interface, allowing for easy iteration and seeking to a specific result.

ZendService\Technorati\GetInfoResult, ZendService\Technorati\BlogInfoResult and
ZendService\Technorati\KeyInfoResult represent exceptions to the above because they don’t belong to a
result set and they don’t implement any interface. They represent a single response object and they act as a
wrapper for additional ZendService\Technorati\Technorati objects, such as ZendService\Technorati\Author and
ZendService\Technorati\Weblog.

The ZendService\Technorati\Technorati library includes additional convenient classes representing specific response
objects. ZendService\Technorati\Author represents a single Technorati account, also known as a blog author or
blogger. ZendService\Technorati\Weblog represents a single weblog object, along with all specific weblog
properties such as feed URLs or blog name. For full details please see ZendService\Technorati\Technorati in the API
reference guide.

ZendService\Technorati\ResultSet is the most essential result set. The scope of this class is to be extended
by a query-specific child result set class, and it should never be used to initialize a standalone object. Each of
the specific result sets represents a collection of query-specific ZendServiceTechnoratiResult objects.

ZendService\Technorati\ResultSet implements the PHPSeekableIterator interface, and you can iterate all
result objects via the PHPforeach() statement.

Iterating result objects from a resultset collection

1
2
3
4
5
6
7
8
9
10
11

// run a simple query$technorati=newZendService\Technorati\Technorati('VALID_API_KEY');$resultSet=$technorati->search('php');// $resultSet is now an instance of// ZendService\Technorati\SearchResultSet// it extends ZendService\Technorati\ResultSetforeach($resultSetas$result){// do something with your// ZendService\Technorati\SearchResult object}

ZendService\Technorati\Result is the most essential result object. The scope of this class is to be extended
by a query specific child result class, and it should never be used to initialize a standalone object.

ZendService\Technorati\CosmosResult represents a single Technorati Cosmos query result object. It is never
returned as a standalone object, but it always belongs to a valid ZendServiceTechnoratiCosmosResultSet object.

ZendService\Technorati\SearchResult represents a single Technorati Search query result object. It is never
returned as a standalone object, but it always belongs to a valid ZendServiceTechnoratiSearchResultSet object.

ZendService\Technorati\TagResult represents a single Technorati Tag query result object. It is never returned
as a standalone object, but it always belongs to a valid ZendServiceTechnoratiTagResultSet object.

ZendService\Technorati\DailyCountsResult represents a single Technorati DailyCounts query result object. It is
never returned as a standalone object, but it always belongs to a valid
ZendServiceTechnoratiDailyCountsResultSet object.

ZendService\Technorati\TagsResult represents a single Technorati TopTags or BlogPostTags query result object.
It is never returned as a standalone object, but it always belongs to a valid
ZendServiceTechnoratiTagsResultSet object.