致命错误:未捕获的异常'异常'消息'错误的响应ID :(请求ID:1)'

时间:2016-09-06 07:35:58

标签: php json-rpc limesurvey

我正在使用limesurvay github.com/trougakoss/LimeSurvey github.com/weberhofer/jsonrpcphp 并且测试代码是

require_once 'C:/wamp/www/limesurvey/jsonrpcphp/src/org/jsonrpcphp/jsonRPCClient.php';
define( 'LS_BASEURL', 'http://10.10.10.29:823/limesurvey/index.php?r=admin/remotecontrol');  // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'admin' );

// the survey to process
$survey_id=989315;

// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL);

//echo $myJSONRPCClient->getinfo();
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );

// receive all ids and info of groups belonging to a given survey
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
print_r($groups, null );

// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );

并解决这些错误:输出结果

( ! ) Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)' in C:\wamp\www\limesurvey\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php on line 185

( ! ) Exception: Incorrect response id: (request id: 1) in C:\wamp\www\limesurvey\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php on line 185

Call Stack
#   Time    Memory  Function                                            Location
1   1.0022  252616  {main}( )                                           ..\test.php:0
2   1.0032  295944  org\jsonrpcphp\JsonRPCClient->get_session_key( )    ..\test.php:25
3   1.0032  296360  org\jsonrpcphp\JsonRPCClient->__call( )             ..\test.php:25

2 个答案:

答案 0 :(得分:1)

我遇到了同样的错误,这是因为我在常规设置中选择了XML API而不是JSON API。

答案 1 :(得分:0)

当我忘记在全局设置中启用JSON-RPC时,我收到了同样的错误。你确定你启用了吗?只是一个想法。

"转到全局设置,选择标签'服务'并选择两个RPC服务(XML-RPC或JSON-RPC)服务之一。"

https://manual.limesurvey.org/Global_settings