I am trying to perform a PHP JSON RemoteControl connection for my LimeSurvey but cannot do so because of errors. The error I'm receiving says:
Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)' in C:\xampp\htdocs\testRPC\JsonRPCClient.php:185 Stack trace: #0 C:\xampp\htdocs\testRPC\test.php(19): org\jsonrpcphp\JsonRPCClient->__call('get_session_key', Array) #1 C:\xampp\htdocs\testRPC\test.php(19): org\jsonrpcphp\JsonRPCClient->get_session_key('admin', 'password') #2 {main} thrown in C:\xampp\htdocs\testRPC\JsonRPCClient.php on line 185
Here is my current test.php (inside "testRPC" folder along with the jsonRPCClient.php I downloaded as mentioned on manual page ). Note that this is the same code snippet as shown on the PHP example of the RemoteControl2API Manual but referring to a survey I have created locally with answers.
<?php
// without composer this line can be used
require_once 'jsonRPCClient.php';
define( 'LS_BASEURL', 'https://localhost/limesurvey/'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'password' );
// the survey to process
$survey_id=543681;
// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient(LS_BASEURL.'/admin/remotecontrol');
// 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 );
I have visited different posts on the forum with the same problem but the solutions haven't helped such as changing the base URL to the full "https://localhost/limesurvey/index.php/admin/remotecontrol" and even the one with index.php?r=admin.
Double checking, I did break point testing and found it does immediately stops and hangs at:
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
This is on Version 2.06+ Build 151018 of LimeSurvey and hosted just on a XAMPP localhost server. I'm thinking it might be because it's on an Apache localhost and not a live server. Nevertheless, can anyone help me with this issue?
I am able to delete survey
and print group details ..
Nobody provided any solution to this problem.
I tried on an Apache localhost and not a live server.getting same exception
Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)' in JsonRPCClient.php on line 185
Exception: Incorrect response id: (request id: 1) in JsonRPCClient.php on line 185