Слияние кода завершено, страница обновится автоматически
Multi Call
<?php
$client = new Jsonrpc_Client(1);
$client->call('http://localhost/server.php', 'addition1', array(3,5));
$client->call('http://localhost/server.php', 'addition2', array(10,20));
/* ... */
$result = $client->execute();
var_dump($result);
//output >>>
/*
array(2) {
[0]=>
array(3) {
["jsonrpc"]=>
string(3) "2.0"
["id"]=>
int(110507766)
["result"]=>
int(8)
}
[1]=>
array(3) {
["jsonrpc"]=>
string(3) "2.0"
["id"]=>
int(1559316299)
["result"]=>
int(30)
}
}
*/
?>
Custom ID
<?php
$client = new Jsonrpc_client(1);
$client->call('http://localhost/server.php', 'addition', array(3,5),"custom_id_001");
$result = $client->execute();
var_dump($result);
//output >>>
/*
array(1) {
[0]=>
array(3) {
["jsonrpc"]=>
string(3) "2.0"
["id"]=>
string(13) "custom_id_001"
["result"]=>
int(8)
}
}
*/
?>
Authentication
<?php
$client = new Jsonrpc_Client(1);
$client->authentication("Username: username", "Password: password");
$client->call('http://localhost/server.php', 'addition1', array(3,5));
$result = $client->execute();
?>
Interface
generate
<?php
$arr = array(
1,
"string",
array("key"=>"value")
);
var_dump(Jsonrpc_Yajl::generate($arr));
/* ==>output
string(28) "[1,"string",{"key":"value"}]";
*/
?>
parse
<?php
$str = '[1,"string",{"key":"value"}]';
var_dump(Jsonrpc_Yajl::parse($str));
/* ==>output
array(3) {
[0]=>
int(1)
[1]=>
string(6) "string"
[2]=>
array(1) {
["key"]=>
string(5) "value"
}
}
*/
?>
jsonrpc 2.0 Error
// Parse error
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}
// Invalid Request
{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request"}}
// Method not found
{"jsonrpc":"2.0","id":null,"error":{"code":-32601,"message":"Method not found"}}
// Invalid params
{"jsonrpc":"2.0","id":null,"error":{"code":-32602,"message":"Invalid params"}}
HTTP Error
// 400
{"jsonrpc":"2.0","id":null,"error":{"code":-32400,"message":"Bad Request"}}
// 401
{"jsonrpc":"2.0","id":null,"error":{"code":-32401,"message":"Unauthorized"}}
// 403
{"jsonrpc":"2.0","id":null,"error":{"code":-32403,"message":"Forbidden"}}
// 404
{"jsonrpc":"2.0","id":null,"error":{"code":-32404,"message":"Not Found"}}
// 500
{"jsonrpc":"2.0","id":null,"error":{"code":-32500,"message":"Internal Server Error"}}
// 502
{"jsonrpc":"2.0","id":null,"error":{"code":-32502,"message":"Bad Gateway"}}
...
// unknow
{"jsonrpc":"2.0","id":null,"error":{"code":-32599,"message":"HTTP Unknow"}}
Curl Error
// 1 CURLE_UNSUPPORTED_PROTOCOL
{"jsonrpc":"2.0","id":null,"error":{"code":-32001,"message":"Curl Unsupported Protocol"}}
// 2 CURLE_FAILED_INIT
{"jsonrpc":"2.0","id":null,"error":{"code":-32002,"message":"Curl Failed Init"}}
// 3 CURLE_URL_MALFORMAT
{"jsonrpc":"2.0","id":null,"error":{"code":-32003,"message":"Curl Url Malformat"}}
// 4
{"jsonrpc":"2.0","id":null,"error":{"code":-32004,"message":"Curl Not Built In"}}
// 5 CURLE_COULDNT_RESOLVE_PROXY
{"jsonrpc":"2.0","id":null,"error":{"code":-32005,"message":"Curl Couldnt Resolve Proxy"}}
// 6 CURLE_COULDNT_RESOLVE_HOST
{"jsonrpc":"2.0","id":null,"error":{"code":-32006,"message":"Curl Couldnt Resolve Host"}}
// 7 CURLE_COULDNT_CONNECT
{"jsonrpc":"2.0","id":null,"error":{"code":-32007,"message":"Curl Couldnt Connect"}}
...
// CURL ERROR UNKNOW
{"jsonrpc":"2.0","id":null,"error":{"code":-32099,"message":"Curl Error Unknow"}}
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )