Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Technorati Cosmos in PEAR

Technorati Cosmos

9:15 am on Aug 22, 2009 (gmt 0)

New User

5+ Year Member

joined:Aug 22, 2009
posts: 3
votes: 0

First I install pear module packages services_technorati, HTTP_request, and XML_serializer.
I has use this code :

* Uses the Services_Technorati package
require_once 'Services/Technorati.php';
// Replace this with your API key
$myApiKey = 'b680ff4d82f7a63c4ef9dce939f407ca';
// Create a new instance based on your key
$technorati = Services_Technorati::factory($myApiKey);
// Specify further options for the search
// We limit the result to ten links
$options = array('limit' => 10);
//Search blogs linking to the PEAR website
$result = $technorati->cosmos('http://pear.php.net', $options);
// Display some basic information
print "Searching for blogs that link to http://pear.php.net\n\n";

printf("Number of blogs found: %d\n", $result['document']['result']['inboundblogs']);
printf("Number of links found: %d\n", $result['document']['result']['inboundlinks']);
// Iterate through the found links
print "\nFirst ten links:\n\n";
foreach ($result['document']['item'] as $link)
printf("Link on %s to %s\n",

But, when I run it in my web browser, there is a bug like this :
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\pear\Technorati\tech.php on line 23

Please tell me how to fix it. Thank's

7:13 pm on Aug 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0

What does the print_r($result['document']['item']); give you?
I have found that from time to time using $array['somevar']['somevar] can give you errors try doing something like this
$tempArr = $result['document']['item'];
foreach($tempArr as $link){
6:10 am on Aug 26, 2009 (gmt 0)

New User

5+ Year Member

joined:Aug 22, 2009
posts: 3
votes: 0

If I do like you said :


There is just blank page. Please tell me what should I do