<?php
 
 
set_include_path(get_include_path() . ":{$_SERVER['DOCUMENT_ROOT']}");
 
error_reporting(E_ALL);
 
 
include_once "lib/core/Query.class.php";
 
include_once "lib/RPCEngine.class.php";
 
 
////////////////////////////////////////////////////////////////////////
 
 
/*
 
Request:
 
    clear && wget --post-data '<?xml version="1.0"?><methodCall><methodName>example.hello_world</methodName><params><param><value><string>Bob Dole</string></value></param></params></methodCall>' -qO- "http://api.example.com/?format=xml"
 
Response:
 
    <?xml version="1.0"?>
 
    <methodResponse>
 
        <params>
 
            <param>
 
                <value>
 
                    <string>Hello Bob Dole, how are you today?</string>
 
                </value>
 
            </param>
 
        </params>
 
    </methodResponse>
 
 
Request:
 
    clear && wget --post-data '<?xml version="1.0"?><methodCall><methodName>example.hello_world</methodName><params><param><value><string>Bob Dole</string></value></param></params></methodCall>' -qO- "http://api.example.com/?format=json"
 
Response:
 
    {"result":"Hello Bob Dole, how are you today?","error":null,"id":null}
 
    
 
Request:
 
    clear && wget --post-data '{ "method": "example.hello_world", "params": ["Bob Dole"], "id": 1}' -qO- "http://api.example.com/?format=xml&input=json"
 
Response:
 
    <?xml version="1.0"?>
 
    <methodResponse>
 
        <params>
 
            <param>
 
                <value>
 
                    <string>Hello Bob Dole, how are you today?</string>
 
                </value>
 
            </param>
 
        </params>
 
    </methodResponse>
 
    
 
Request:
 
    clear && wget --post-data '{ "method": "example.hello_world", "params": ["Bob Dole"], "id": 1}' -qO- "http://api.example.com/?format=xml&input=json&format=json"
 
    clear && wget --post-data '{ "method": "help.list_all", "params": ["Bob Dole"], "id": 1}' -qO- "http://api.example.com/?format=xml&input=json&format=json"
 
Response:
 
    {"result":"Hello Bob Dole, how are you today?","error":null,"id":null}    
 
*/
 
 
$output = Get::param('format','/^(json|xml)$/','xml');
 
$input = Get::param('input','/^(json|xml)$/','xml');
 
 
$request = Post::raw();
 
 
$RPCRequest = RPCRequestFactory::create($request, $output, $input);
 
 
$RPCEngine = RPCEngine::factory();
 
$RPCResult = $RPCEngine->execute($RPCRequest);
 
 
$RPCResult->render();
 
?>
 
 
 |