Tuesday June 26, 2007

Enter Shikari tonight

Gigs

Going to the pub last night (and Sunday, and Saturday, and Friday) might not have been such a brilliant idea because I'm rather knackered and Enter Shikari is playing at Waterfront tonight so I won't have a chance to get much sleep.

Sucks to be me! ;)

Technorati pings

Software

Unless I messed up my code, this journal should be sending Technorati pings again. I'm still getting reasonable traffic from the site for older entries so it should be worth it to get listed there again.

(On that topic, I'm considering to return to a more distributed blogging effort, with different blogs for different areas of interest, in order to build more dedicated audiences for each topic. The new profile/music site already is a step towards such a setup, after all.)

Anyway, here's the PHP code that (should) send a proper ping to Technorati:

class Ping
{
function httpPost( $host, $port, $uri, $data, $userAgent = "KikiCMS/0.99" )
{
$url = "http://${host}:${port}${uri}";

$fp = @fsockopen( $host, $port, $errno, $errstr, 5);
if (!$fp)
return false;

$out = "POST ${uri} HTTP/1.1\r\n";
$out .= "Host: ${host}\r\n";
$out .= "Content-Type: text/xml\r\n";
$out .= "Content-Length: ". strlen($data). "\r\n";

fwrite($fp, $out);
fwrite($fp, "\r\n");
fwrite($fp, $data);
fwrite($fp, "\r\n");
fpassthru($fp);

fclose($fp);
return true;
}

function technoRati( $title, $url )
{
$uTitle = htmlspecialchars($title);
$uUrl = htmlspecialchars($url);
$xml = "<?xml version=\"1.0\"?>\n"
$xml .= "<methodCall>\n";
$xml .= "<methodName>weblogUpdates.ping</methodName>\n";
$xml .= "<params>\n";
$xml .= "<param>\n<value>$uTitle</value>\n</param>\n";
$xml .= "<param>\n<value>$uUrl</value>\n</param>\n";
$xml .= "</params>\n";
$xml .= "</methodCall>\n";

Ping::httpPost( "rpc.technorati.com", 80, "/rpc/ping", $xml );
}

Include the class when you save (insert) an entry with Ping::technoRati( "My blog", "myurl" ) and you should be ready to go.


© Copyright 1995-2008 Robert John Kaper. All rights reserved.

Tom has more friends but mine are prettier! (#1/1)