Meerkat XML-RPC Interface Test-Suite



For documentation and more, run the "introspection" test

new xmlrpcval(5209, "int"), "search" => new xmlrpcval("/Java|p2p/", "string"), "search_what" => new xmlrpcval("dc:subject", "string"), "time_period" => new xmlrpcval("30DAY", "string"), "ids" => new xmlrpcval(0, "int"), "descriptions" => new xmlrpcval(200, "int"), "categories" => new xmlrpcval(0, "int"), "channels" => new xmlrpcval(0, "int"), "dates" => new xmlrpcval(0, "int"), "dc" => new xmlrpcval(1, "int"), "num_items" => new xmlrpcval(5, "int"), ), "struct" ); $test == 'system.listMethods' and introspection(); $test == 'meerkat.getChannelsByCategory' and test_getChannelsByCategory($category); $test == 'meerkat.getChannelsBySubstring' and test_getChannelsBySubstring($substring); $test == 'meerkat.getChannels' and test_getChannels(); $test == 'meerkat.getCategories' and test_getCategories(); $test == 'meerkat.getCategoriesBySubstring' and test_getCategoriesBySubstring($substring); $test == 'meerkat.getItems' and test_getItems($recipe); function test_getChannels () { global $server_url; print "

meerkat.getChannels()


\n"; $f = new xmlrpcmsg('meerkat.getChannels', array()); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function test_getChannelsByCategory ($category) { global $server_url; print "

meerkat.getChannelsByCategory($category)


\n"; $f = new xmlrpcmsg('meerkat.getChannelsByCategory', array(new xmlrpcval($category, "int"))); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function test_getChannelsBySubstring ($substring) { global $server_url; print "

meerkat.getChannelsBySubstring($substring)


\n"; $f = new xmlrpcmsg('meerkat.getChannelsBySubstring', array(new xmlrpcval($substring, "string"))); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function test_getCategories () { global $server_url; print "

meerkat.getCategories()


\n"; $f = new xmlrpcmsg('meerkat.getCategories', array()); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function test_getCategoriesBySubstring ($substring) { global $server_url; print "

meerkat.getCategoriesBySubstring($substring)


\n"; $f = new xmlrpcmsg('meerkat.getCategoriesBySubstring', array(new xmlrpcval($substring, "string"))); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function test_getItems ($recipe) { global $server_url; print "

meerkat.getItems({see details below})


\n"; $f = new xmlrpcmsg('meerkat.getItems', array($recipe)); print '
' . htmlentities($f->serialize()) . '
'; $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(1); $r=$c->send($f); if (!$r) { die("send failed"); } $v=$r->value(); } function rpc_call($client, $msg) { global $server_url; $r=$client->send($msg); if (!$r) { print "
ERROR: couldn't send message
\n"; return 0; } else { if (!$r->faultCode()) { return $r->value(); } else { print "Fault: "; print "Code: " . $r->faultCode() . " Reason '" .$r->faultString()."'
"; return 0; } } } function introspection () { global $server_url; $f=new xmlrpcmsg('system.listMethods'); $c = new xmlrpc_client($server_url, "www.oreillynet.com", 80); $c->setDebug(0); $v=rpc_call($c, $f); print "

introspection()

\n"; print "

methods available at http://" . $c->server . ":" . $c->port . $c->path . "

\n"; if ($v) { for($i=0; $i<$v->arraysize(); $i++) { $mname=$v->arraymem($i); print "

" . $mname->scalarval() . "

\n"; $f=new xmlrpcmsg('system.methodHelp'); $f->addParam(new xmlrpcval($mname->scalarval(), "string")); $w=rpc_call($c, $f); if ($w) { $txt=$w->scalarval(); if ($txt!="") { print "

Documentation

${txt}

\n"; } else { print "

No documentation available.

\n"; } } $f=new xmlrpcmsg('system.methodSignature'); $f->addParam(new xmlrpcval($mname->scalarval(), "string")); $w=rpc_call($c, $f); if ($w) { print "

Signature

\n"; if ($w->kindOf()=="array") { for($j=0; $j<$w->arraysize(); $j++) { $x=$w->arraymem($j); $ret=$x->arraymem(0); print "" . $ret->scalarval() . " " . $mname->scalarval() ."("; if ($x->arraysize()>1) { for($k=1; $k<$x->arraysize(); $k++) { $y=$x->arraymem($k); print $y->scalarval(); if ($k<$x->arraysize()-1) { print ", "; } } } print ")
\n"; } } else { print "Signature unknown\n"; } print "

\n"; } } } } ?>