DuckSoup documentation for Technorati API


Getting started

As said in the overview, the whole ducksoup code is wrapped into a single class, which resides in the script duckSoup.php in the Duck Soup package.

The name of the class is duckSoup . So to get started, first you include duckSoup.php in your script and create an object from the duckSoup class

include "duckSoup.php";

$api = new duckSoup;

Parameters / Variables

The most important parameter that is to be assigned to the duckSoup class is your 32 character Technorati API key. You assign it to your newly created object as follows

$api->api_key="c21f9630e84e582895e5e9da586d792f";

The next important parameter is the type parameter. It is the type of API you want to use. (cosmosQuery,searchQuery,bloginfo..). Duck Soup supports all technorati APIs and here is the table values that are accepted by the ‘type’ parameter

API name Parameter (type) value
CosmosQuery cosmos
SearchQuery search
GetInfoQuery getinfo
BlogInfoQuery bloginfo
OutboundQuery outbound
TagQuery taginfo
TopTags toptags
KeyInfo keyinfo
BlogPostTags blogposttags
DailyCounts dailycounts

So assigning the ‘type’ would look like

$api->type = 'search';

And now comes the ‘params’ parameter. It is an array of parameters that is to be passed as query to the Technorati server. Every API has its own supported parameters (defined by Technorati). Full information can be found on the TechnoratiAPI wiki. Here is a brief list of supported parameters for each API

CosmosQuery (cosmos)
url *   type   limit   start   current   claim   highlight

SearchQuery (search)
query *   start   limit   claim   language   authority

GetInfoQuery (getinfo)
username *

BlogInfoQuery (bloginfo)
url *

OutboundQuery (outbound)
url *  start

TagInfoQuery (taginfo)
tag *   limit   start   excerptsize   topexcerptsize

TopTagsQuery (toptags)
(no parameters)

KeyInfoQuery (keyinfo)
(no parameters)

BlogPostTags Query (blogposttags)
url *  limit

DailyCounts Query (dailycounts)
q *  limit

Here’s an example parameter assignment

$api->params = array('query' => 'Apples', 'limit' => '10');

Now everything’s set, all we need to do is connect to Technorati and retrieve the data. For that the duckSoup class has the method (function) get_content(). It does all the processes and returns the data in trees.

$my_data = $api->get_content();

There we go! To see the structure of the data array, refer to the Tree structures. All the code we wrote in this section, would be like this in a nutshell

<?php
	include "duckSoup.php";

	$api = new duckSoup;
	$api->api_key="c21f9630e84e582895e5e9da586d792f";
	$api->type = 'search';
	$api->params = array('query' => 'Apples', 'limit' => '10');
	$my_data = $api->get_content();

	print_r($my_data);	// Prints the array

?>


Add to Technorati Add to Del.icio.us Add to Furl Add to Yahoo My Web 2.0 Add to Reddit Add to Digg Add to Spurl Add to Wists Add to Simpy Add to Newsvine Add to Blinklist Add to Fark Add to Blogmarks Add to GoldenFeed

Advertisements
  1. September 17th, 2009

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: