Description
Technorati is a blog search engine. By indexing blogs and exploring links between them, they provide tools for monitoring online conversations taking place on and between blogs. By far the richest source of this information is through their REST-based API, to which this module provides an OO PHP interface. Full documentation for Technorati's API is available on their developers' wiki. To use the API you will need an API key.
To protect against future changes to the underlying API it is accessed using a factory method:
$tapi =& Services_Technorati::factory($api_key); |
The Technorati API limits you to 500 queries per day so those wishing to use it in a high-demand environment will want to employ some caching. Services_Technorati provides support for any caching system with a Cache_Lite-like API. To use a cache, you will need to create it and then pass it to the class in the factory:
$tapi =& Services_Technorati::factory($api_key, $cache_object); |
Once you have instantiated the object you can start passing in queries. Each call takes the form of methodName(keyParameter, options) where options is an array.
Table 60-1. Query types and their options
Query Name | Key Parameter | Permitted Options |
---|
cosmos | url | type, limit, start, current, claim, highlight |
search | query keywords | start, limit, claim |
outbound | url | start |
tag | tag | limit, start, format, excerptsize, topexcerptsize |
topTags | - | limit, start |
blogPostTags | url | limit |
getInfo | username | - |
blogInfo | url | - |
(NB. Support for Technorati's attention.XML services is also included in accordance with the spec, but those services are currently in a state of flux so cannot be relied upon.)
The value returned from each query will be either an array representing the unserialized XML or a PEAR Error.
Example 60-1.
An example return from the blogInfo query (for 'jystewart') is:
Array
(
[version] => 1.0
[document] => Array
(
[result] => Array
(
[username] => jystewart
[firstname] => James
[lastname] => Stewart
)
[item] => Array
(
[0] => Array
(
[weblog] => Array
(
[name] => little more than a placeholder
[url] => http://james.anthropiccollective.org
[rssurl] => http://james.anthropiccollective.org/index.rdf
[atomurl] => http://james.anthropiccollective.org/atom.xml
[inboundblogs] => 52
[inboundlinks] => 82
[lastupdate] => 2005-08-27 09:01:42 GMT
[rank] => 7483
[lat] => 0
[lon] => 0
[lang] => 26110
[foafurl] => http://jystewart.net/foaf.rdf
)
)
[1] => Array
(
[weblog] => Array
(
[name] => something approaching a photo album
[url] => http://approach.anthropiccollective.org
[rssurl] =>
[atomurl] =>
[inboundblogs] => 1
[inboundlinks] => 1
[lastupdate] => 2004-08-13 17:40:02 GMT
[rank] => 240760
[lat] => 0
[lon] => 0
[lang] => 0
)
)
[2] => Array
(
[weblog] => Array
(
[name] => grwifi.net : wireless internet (wifi) in grand rapids, michigan
[url] => http://grwifi.net
[rssurl] =>
[atomurl] => http://grwifi.net/atom/
[inboundblogs] => 9
[inboundlinks] => 11
[lastupdate] => 2005-04-15 19:44:46 GMT
[rank] => 50688
[lat] => 0
[lon] => 0
[lang] => 26110
)
)
[3] => Array
(
[weblog] => Array
(
[name] => a work on process
[url] => http://jystewart.net/process
[rssurl] => http://jystewart.net/process/feed/
[atomurl] => http://jystewart.net/process/feed/atom/
[inboundblogs] => 3
[inboundlinks] => 3
[lastupdate] => 2005-08-31 20:44:38 GMT
[rank] => 132735
[lat] => 0
[lon] => 0
[lang] => 26110
[foafurl] => http://jystewart.net/foaf.rdf
)
)
)
)
) |
|
Full details of the XML returned by Technorati is included on the developers' wiki