On of the latest things on my to-do list has been implementing a ping function in my CakePHP blog. I was hoping to find some code to copy and paste directly from CakePHP Google Group, but it seems that none has done it yet, and I ended up doing it myself.
This is how I did it:
- Download the XMLRPC PHP class from http://sourceforge.net/projects/phpxmlrpc/, extract it and move the file libs/xmlrpc.inc into app/vendors. Remember to change the fileextension to .php
- Include the file by adding this in the start of your controller:
vendor('xmlrpc');class PostsController extends AppController { - Now create a separat ping function:
function ping() { // Make an object to represent our server. $server = new xmlrpc_client('/rpc/ping','rpc.technorati.com', 80); $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval("Gersh.no"), new xmlrpcval("http://www.gersh.no"))); // Send a message to the server. $result = $server->send($message); if (!$result || $result->faultCode()) return(false); else return(true); } - Call this function whenever you want to ping and update or change with:
$this->ping();
What is ping?
any blog authoring tools automatically ping one or more servers each time the blogger creates a new post (or updates an old one.) That is, the tool sends an XML-RPC signal to one or more “ping servers,” which can then generate a list of blogs that have new material.
(from wikipedia):
thanx for that script…
i hopeit will work fine, i didn´t test it yet, but bookmarked it, so i can use it later!