Technorati est un moteur de recherche pour blog. En indexant les blogs et en explorant les liens entre eux, ce moteur fourni des outils pour suivre les conversations en ligne qui se forment entre les blogs. By far the richest source of this information is through their REST-based API, to which this module provides an OO PHP interface. La documentation complète pour l'API de Technorati est disponible sur le wiki des développeurs. Pour utiliser l'API vous devez obtenir une clé d'API.
Pour se protéger de modification future de l'API sous-jacente, on y accède par une méthode factory:
<?php
$tapi =& Services_Technorati::factory($api_key);
?>
L'API de Technorati vous limite à 500 par jour ce qui implique la nécéssiré d'utiliser un système de cache pour les environements à demande élevée. Services_Technorati fourni un support pour tous les systèmes de cache ayant une API comme celle de Cache_Lite. Pour utiliser un cache, Vous devez en créer un et le passer à la classe dans la méthode factory:
<?php
$tapi =& Services_Technorati::factory($api_key, $cache_object);
?>
Une fois que vous avez instancié l'objet, vous pourvez commencer à passer des requêtes. Chaque appel prend la forme de nomDeMethode(parametreClé, options) où options est un tableau associatif.
Nom de la requête | Paramètre clé | Options disponibles |
---|---|---|
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.)
La valeur retournée par chaque requête sera selon les cas un tableau représentant le XML désérialisé ou une erreur PEAR.
Un exemple de retour avec la requête blogInfo (for 'jystewart') est:
<?php
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
)
)
)
)
)
?>
Le détail complet du XML qui est retourné parTechnorati est décrit sur le wiki de développement