Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

RemoteControlAPI jsonRPCClient PHP Connection Not Working

  • jsanjose
  • jsanjose's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 5 months ago #127728 by jsanjose
Good day,

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', 'http://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 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 );



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 "http://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?


Thank You and have a nice day.
The topic has been locked.
More
8 years 5 months ago #128203 by prak198
I am also facing the same exception when adding a survey

$add=$myJSONRPCClient->add_survey($sessionKey, 1233, 'aaa', 'en', 'G');

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
The topic has been locked.
More
5 years 11 months ago #168316 by ashna
I have the exact same problem. Any ideas? It´s been a while.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose