X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=demo%2Fclient%2Fcomment.php;h=2c34d3f2858597e4bc01a71e607ddea252d302e9;hb=eb00ccc94d22b89172a7dedff973da779875b9f3;hp=7133cf95d9e18145f0d66273e0024b3d6f1e8b7e;hpb=26ac91603dc5dab166667622bbc5e7de6d585f3c;p=plcapi.git diff --git a/demo/client/comment.php b/demo/client/comment.php index 7133cf9..2c34d3f 100644 --- a/demo/client/comment.php +++ b/demo/client/comment.php @@ -1,185 +1,211 @@ "; exit(); } -function dispatch($client, $method, $args) { - $msg=new xmlrpcmsg($method, $args); - $resp=$client->send($msg); - if (!$resp) { print "

IO error: ".$client->errstr."

"; bomb(); } - if ($resp->faultCode()) { - print "

There was an error: " . $resp->faultCode() . " " . - $resp->faultString() . "

"; - bomb(); - } - return php_xmlrpc_decode($resp->value()); +function bomb() +{ + print ""; + exit(); +} + +function dispatch($client, $method, $args) +{ + $req = new PhpXmlRpc\Request($method, $args); + $resp = $client->send($req); + if (!$resp) { + print "

IO error: " . $client->errstr . "

"; + bomb(); + } + if ($resp->faultCode()) { + print "

There was an error: " . $resp->faultCode() . " " . + $resp->faultString() . "

"; + bomb(); + } + + $encoder = new PhpXmlRpc\Encoder(); + return $encoder->decode($resp->value()); } // create client for discussion server -$dclient=new xmlrpc_client("${mydir}/discuss.php", - "xmlrpc.usefulinc.com", 80); +$dclient = new PhpXmlRpc\Client("http://xmlrpc.usefulinc.com/${mydir}discuss.php"); // check if we're posting a comment, and send it if so -@$storyid=$_POST["storyid"]; +@$storyid = $_POST["storyid"]; if ($storyid) { + // print "Returning to " . $HTTP_POST_VARS["returnto"]; - // print "Returning to " . $HTTP_POST_VARS["returnto"]; - - $res=dispatch($dclient, "discuss.addComment", - array(new xmlrpcval($storyid), - new xmlrpcval(stripslashes - (@$_POST["name"])), - new xmlrpcval(stripslashes - (@$_POST["commenttext"])))); + $res = dispatch($dclient, "discuss.addComment", + array(new PhpXmlRpc\Value($storyid), + new PhpXmlRpc\Value(stripslashes(@$_POST["name"])), + new PhpXmlRpc\Value(stripslashes(@$_POST["commenttext"])),)); - // send the browser back to the originating page - Header("Location: ${mydir}/comment.php?catid=" . - $_POST["catid"] . "&chanid=" . - $_POST["chanid"] . "&oc=" . - $_POST["catid"]); - exit(0); + // send the browser back to the originating page + Header("Location: ${mydir}/comment.php?catid=" . + $_POST["catid"] . "&chanid=" . + $_POST["chanid"] . "&oc=" . + $_POST["catid"]); + exit(0); } // now we've got here, we're exploring the story store ?> -meerkat browser + +meerkat browser

Meerkat integration

-

Make a comment on the story

-
-

Your name:

-

Your comment:

- -" /> - - - -
- new xmlrpcval($chanid, "int"), - "ids" => new xmlrpcval(1, "int"), - "descriptions" => new xmlrpcval(200, "int"), - "num_items" => new xmlrpcval(5, "int"), - "dates" => new xmlrpcval(0, "int") - ), "struct"))); - } -?> -
-

Subject area:
-

- -

News source:
- -

- - - -

- -
+ $chanid = 0; +} - +$client = new PhpXmlRpc\Client("http://www.oreillynet.com/meerkat/xml-rpc/server.php"); -

Stories available

- +if (@$_GET["comment"] && + (!@$_GET["cdone"]) +) { + // we're making a comment on a story, + // so display a comment form + ?> +

Make a comment on the story

+ +

Your name:

+ +

Your comment:

+ + "/> + + + + "; - print ""; - print "\n"; - // now look for existing comments - $res=dispatch($dclient, "discuss.getComments", - array(new xmlrpcval($v['id']))); - if (sizeof($res)>0) { - print "\n"; - } - print "\n"; - } -?> -
" . $v['title'] . "
"; - print $v['description'] . "
"; - print "Read full story "; - print "Comment on this story"; - print ""; - print "

" . - "Comments on this story:

"; - for($i=0; $iFrom: " . htmlentities($s['name']) . "
"; - print "Comment: " . htmlentities($s['comment']) . "

"; - } - print "

- new PhpXmlRpc\Value($chanid, "int"), + "ids" => new PhpXmlRpc\Value(1, "int"), + "descriptions" => new PhpXmlRpc\Value(200, "int"), + "num_items" => new PhpXmlRpc\Value(5, "int"), + "dates" => new PhpXmlRpc\Value(0, "int"), + ), "struct"))); + } + ?> +
+

Subject area:
+

+ +

News source:
+ +

+ + + +

+ +
+ + + +

Stories available

+ + "; + print ""; + print "\n"; + // now look for existing comments + $res = dispatch($dclient, "discuss.getComments", + array(new PhpXmlRpc\Value($v['id']))); + if (sizeof($res) > 0) { + print "\n"; + } + print "\n"; + } + ?> +
" . $v['title'] . "
"; + print $v['description'] . "
"; + print "Read full story "; + print "Comment on this story"; + print ""; + print "

" . + "Comments on this story:

"; + for ($i = 0; $i < sizeof($res); $i++) { + $s = $res[$i]; + print "

From: " . htmlentities($s['name']) . "
"; + print "Comment: " . htmlentities($s['comment']) . "

"; + } + print "

+ + -
+

-Meerkat powered, yeah! -$Id$

+ Meerkat powered, yeah! +