Technorati API OUCH!

Status
Not open for further replies.

elusid

New member
May 10, 2007
21
0
0
Having a helluva time working with technorati's API...

All I need is to grab the top 10-20 or so tags...

here is my code so far... its been timing out on me or returning nothing what am I doing wrong here?

PHP:
<?php
header ("content-type: text/xml");

// Your technorati api key
$api_key = 'my api key';


$url = 'http://api.technorati.com/toptags?key='.$api_key';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
curl_close($ch);
echo $page;

?>
 


1) Lookup curl_error and error check your call.
2) Make sure your client is not set as PHP some sites dont like that.
3) You want text or pics back? echo may not be the best choice here.
 
1) Lookup curl_error and error check your call.
2) Make sure your client is not set as PHP some sites dont like that.
3) You want text or pics back? echo may not be the best choice here.

I got it to return something by adding the server time out function...

PHP:
set_time_limit(0);

and now I get something..

XML Parsing Error: no element found
Location: http://localhost/top_tags.php
Line Number 1, Column 1:

right now I just want get the xml return from the query, I've searched for good tutorials regarding the technorati api and cant find squat...
 
$url = 'http://api.technorati.com/toptags?key='.$api_key.'';

Try replacing that line with that -- you escaped the ' at the
beginning of the $api_key - but not at the end.

 
Hey Nickycakes,

nah that code is dated it seems was returning some very strange errors... and I am not used to scraping using strstr function.... thanks for your help though!

oh btw I was shocked to get your response i've been reading your blog quite a bit lately good stuff and Beantown is only 2 hours from me.

the code on this old post may still work
doesn't use the api, just scrapes directly
Free Traffic From Technorati | NickyCakes.com
 
doh! that could have been it... after seeing nickycakes code I gave up on the API and decided to just ole fashion scrape it....

$url = 'http://api.technorati.com/toptags?key='.$api_key.'';

Try replacing that line with that -- you escaped the ' at the
beginning of the $api_key - but not at the end.

 
Ok so I gave up on the API it sucks anyway. Here is how I solved my problem feel free to use this code for whatever it scrapes the top 15 technorati search terms and if you read Nickycakes post you can see why its useful....

PHP:
<?php
//////////////////////////////////////////
//Technorati Top 15 search terms scraper
//http://www.cashvolume.com
////////////////////////////////////////
function techno(){
$web =   file_get_contents('http://www.technorati.com/pop/');
  
$regex = "/<a href=\"\/search\/(.+?)\" class=\"trk\" title=/";
preg_match_all($regex, $web, $output);

echo implode("<br>", $output[1]);
        
        
        return($keywords);
    }
    
echo    techno();

?>
 
Status
Not open for further replies.