PHP client example

This client connects to the sample C++ server.

<?php

$client = new fastrpc_server_proxy("http://localhost:2424/RPC2");
if (!$client) {
    echo "client init failed";
}


$res = $client->method_call("system.listMethods");

if (is_fastrpc_error($res)) {
    printf("error: err %d, sts %d, msg %s \n",
           $res->error_type, $res->status,
           $res->statusMessage);
    die;
}

if (is_fastrpc_fault($res)) {
    printf("fault: sts %d, msg %s\n",
           $res->status, $res->statusMessage);
    die;
}

echo "<pre>";
print_r($res);
echo "</pre>" ;

$res = $client->method_call("system.methodSignature", $res->get(4));

if (is_fastrpc_error($res)) {
    printf("error: err %d, sts %d, msg %s \n",
                            $res->error_type, $res->status,
                            $res->statusMessage);
                            die;

}

if (is_fastrpc_fault($res)) {
     printf("fault: sts %d, msg %s\n",
            $res->status, $res->statusMessage);
     die;
}

echo "<pre>";
print_r($res);
echo "</pre>" ;

$res = $client->method_call("test1", 2, "hello");

if (is_fastrpc_error($res)) {
    printf("error: err %d, sts %d, msg %s \n",
           $res->error_type, $res->status,
           $res->statusMessage);
    die;
}

if (is_fastrpc_fault($res)) {
    printf("fault: sts %d, msg %s\n",
           $res->status, $res->statusMessage);
    die;
}

echo "<pre>";
print_r($res);
echo "</pre>" ;

printf("\nSatus is %d", $res->get("status"));

phpinfo();
?>

< back