Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/server.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mark Rolich  >  JSON RPC Client and Server  >  examples/server.php  >  Download  
File: examples/server.php
Role: Example script
Content type: text/plain
Description: Example server
Class: JSON RPC Client and Server
Implements JSON RPC protocol client and server
Author: By
Last change: Added support and tests for optional parameters in service methods
Date: 2 years ago
Size: 511 bytes
 

Contents

Class file image Download
<?php
include '../JsonRpcException.php';
include 
'../JsonRpcServer.php';
include 
'MathService.php';
include 
'DataService.php';
include 
'OptionalParamsService.php';

$math = new MathService();
$data = new DataService();
$optional = new OptionalParamsService();
$server = new JsonRpcServer();

$server->addService($math);
$server->addService($data);
$server->addService($optional);

$request file_get_contents("php://input");
$result $server->process($request);

if (
$result !== null) {
    echo 
$result;
}
?>