DuckSoup documentation
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
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
?>
« Overview Tree structures»
