| 1 |
<?php |
| 2 |
|
| 3 |
header("Content-Type: application/json"); |
| 4 |
|
| 5 |
require_once("./JSON.php"); |
| 6 |
$json = new Services_JSON; |
| 7 |
|
| 8 |
$id = $_REQUEST['id']; |
| 9 |
$method = $_REQUEST['method']; |
| 10 |
$params = $json->decode($_REQUEST['params']); |
| 11 |
$callback = $_REQUEST["callback"]; |
| 12 |
|
| 13 |
switch($method){ |
| 14 |
case "jsonpJsonRpc10EchoNamed": |
| 15 |
case "jsonpJsonRpc11Echo": |
| 16 |
case "jsonpJsonRpc11EchoNamed": |
| 17 |
case "jsonpJsonRpc10Echo": |
| 18 |
if ( ($method=="jsonpJsonRpc10EchoNamed")||($method=="jsonpJsonRpc11EchoNamed")){ |
| 19 |
$message = $params->message; |
| 20 |
}else{ |
| 21 |
$message = $params[0]; |
| 22 |
} |
| 23 |
if ($message){ |
| 24 |
switch($method){ |
| 25 |
case "jsonpJsonRpc11Echo": |
| 26 |
case "jsonpJsonRpc11EchoNamed": |
| 27 |
$res = "{'id': '$id', result: '$message'}"; |
| 28 |
break; |
| 29 |
default: |
| 30 |
$res = "{'id': '$id', result: '$message', 'error':''}"; |
| 31 |
break; |
| 32 |
} |
| 33 |
}else{ |
| 34 |
$res = "{'id': '$id', error: {'code': 100, 'message':'no message provided'}}"; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
print "$callback($res)"; |
| 39 |
|
| 40 |
?> |