Tumblr tag list

In two of my tumblr blogs, Type Nesting and Looking For Glove there is a list of all the tags used in that blog. Tumblr offers a way to generate such list via its api, but the api is very slow and there is always a need for more then one call.

Below is a PHP script that makes crates a js file that has all the tags in a sorted array that looks like this

var tagsArray=new Array("BLACK","BLUE","CAPITAL A","CAPITAL B");

I have a cron that runs it every couple of hours on my server.

$myblog="lookingforglove"; //     modify this line     http://myblog.tumblr.com
$stack = array();
$chunk = 50;  
while (!$done)
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	$buffer = curl_exec($ch);
	if (empty($buffer))
		$buffer= substr($buffer, 5,-3);
		$jpost= $json_o['posts'];
		foreach  ($jpost as $jpostItem)
			foreach  ($jtags as $jtagsItem)
	if (sizeof($jpost)< $chunk)   ///no more posts
		{ $done=true;}
$longString="var tagsArray=new Array(\"";
$longString.=implode("\",\"", $stack);

$fp = fopen($filename, 'w');
fwrite($fp, $longString);

The javascript used in the theme where I want to have the tags.

Leave a Reply