revjim.net

May 1st, 2003:

PEAR::XML_RPC_Server tutorial

While I’ve managed to find lots of PHP XML-RPC information, I’ve
found very little in regard to using PEAR to make an XML-RPC Server.
Here’s a snippet of code to get you started:

// Include the libraries
require_once 'XML/RPC/Server.php';

// This array maps XML-RPC methods to functions.
$map = array('example.getTime' => array('function' => 'gettime'));

/* Creating a new object of this type automatically
 * Parsed the XML-RPC request and handles the
 * response.
 */
$svr = new XML_RPC_Server($map);

// Bye bye
exit;

/* Our function. Mapped to method example.getTime.
 * When called, example.getTime will accept one
 * parameter -- the format to provide the date in.
 * In all cases, this method merely returns the date.
 */
function gettime($p) {

        // Get the first parameter
        $format = $p->getParam(0);

        // Look to see if it was supplied
        if (empty($format)) {
                // In case it wasn't, this is our default.
                $format = 'Y-m-d h:i:s';
        } else {
                // Get the value of the parameter.
                $format = $format->scalarval();
        }

        // Build a return value
        $retval = date($format,time());

        // Return it as a response
        return new XML_RPC_Response(new XML_RPC_Value($retval, "string")); 

}

I used the long versions of all the functions in order to make
certain that you understand what is going on in each step. Functions
like XML_RPC_decode() make life a lot easier and you may want
to consider playing with them a bit.

blo.gs cloud interface

blo.gs has a great href="http://blo.gs/cloud.php">cloud Interface that performs roughly
the same functionality I was href="http://revjim.net/archives/2003/04/30/9497.php">speaking about
yesterday. The only problem with their interface is that it only
sends pings that were made to blo.gs, and not any of those that were
imported from weblogs.com. Additionally, it will only send you
notifications for EVERYTHING as opposed to allow you to request
notification for only one or two blogs. With proper cloud notation in an
RSS feed, and the ability to subscribe to a feed via XML-RPC, this could
really work well. I wonder what blo.gs’s plans are for the future?

Wheel ‘O Yum

A few years ago, a co-worker and I considered writing an application
very similar to the Wheel ‘O
Yum
. In fact, I think we even decided that it should use a wheel to
choose. We never built it, we just used it as something to talk about
when we should have been deciding where to eat.

The Wheel ‘O Yum is a program to aid in deciding
where to eat. All too often, excess time is spent among groups trying to
decide. The Wheel ‘O Yum allows one or more people to vote on their
favorite restaurants and spin the wheel for a random–but
educated–restaurant.