File: examples/exampleViaPHP.php

Recommend this page to a friend!
  Classes of Chris Jeffries  >  PHP JSON RPC 2.0 Server  >  examples/exampleViaPHP.php  >  Download  
File: examples/exampleViaPHP.php
Role: Example script
Content type: text/plain
Description: Example using the PHP CURL Client
Class: PHP JSON RPC 2.0 Server
Handle to HTTP requests in JSON RPC v2.0 format
Author: By
Last change:
Date: 2 years ago
Size: 1,273 bytes


Class file image Download
function process() {
$_POST['btn'])) {
$request = json_decode($_POST['txt']);

        if (
json_last_error() > 0) {
'<p style="color:red;">'.json_last_error_msg() . '</p>';
        } else {
$cli = new jsonrpcClient();
$request->params )) {
$request->params = (object) [];
$result = $cli->request('http://localhost/test/JSON_RPC/index.php', $request->method, $request->id, json_encode($request->params));
//$result = json_encode($result, JSON_PRETTY_PRINT);
echo "
        <title>JSON-RPC tester via PHP CURL</title>

        <h1>JSON-RPC tester via PHP CURL</h1>
        <p>This tester sends data back to the server which then uses
        the JSON-RPC PHP CLient to fire off a request to the server.
        It inserts the server response in the page that is sent back
        to the browser.
        <form method=post>
            <textarea id=txt name=txt cols=50 rows=10>{
            <br />
            <input type=submit name=btn id=btn value = 'Send!'>
        <?php process(); ?>

For more information send a message to info at phpclasses dot org.