RemoteControl & import_survey error

5 years 9 months ago #95030 by Exile13
Exile13 created the topic: RemoteControl & import_survey error

I'm busy building an application which uses the remote control functions using json-rpc and PHP.

The simple methods are working, but when i try to import a survey it returns with an internal 500 error @point 3 below:

my process is simple:
1 - Check to see if ls survey file exists (.lss)
2 - get a new remote session key
3 - import base64'ed survey file
4 - release the remote session

error in html:

1: File exists: bool(true)
2: SessionKey: string(32) "ddj44badgt4hgqc25nx3mwpbsp95ks8x"
3: Warning: fopen(http://???/limesurvey/index.php/admin/remotecontrol) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /var/www/???/jsonRPCClient.php on line 133

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://???/limesurvey/index.php/admin/remotecontrol' in /var/www/???/jsonRPCClient.php:141 Stack trace: #0 /var/www/limesurvey_android/rd_functions.php(175): jsonRPCClient->__call('import_survey', Array) #1 /var/www/???/rd_functions.php(175): jsonRPCClient->import_survey('ddj44badgt4hgqc...', 'PD94bWwgdmVyc2l...', 'lss', NULL, '661121') #2 /var/www/???/rd_functions.php(18): importSurvey('661121', 'limesurvey_surv...') #3 {main} thrown in /var/www/???/jsonRPCClient.php on line 141

php code:

function importSurvey($SurveyID, $strFilename)
echo "<br>1: File exists: "; var_dump(file_exists($file));
return "File not found @ ". $file;

$hFile = fopen($file,"r");

$data = fread($hFile, filesize($file));
$data = base64_encode($data);

if($data == null)
return "Error reading file content: ". $file;

$rpcClient = new jsonRPCClient($DATABASE_SETTINGS[$_SERVER[SERVER_NAME]]->rpcClient ."/limesurvey/index.php/admin/remotecontrol");


// receive session key
$SessionKey = $rpcClient->get_session_key( "user", "****" );
echo "<br>2: SessionKey:"; var_dump($SessionKey);
if($SessionKey == null)
return "Error getting ls session key: ". $SessionKey;

// receive all ids and info of groups belonging to a given survey
//$groups = $rpcClient->list_groups( $SessionKey, $SurveyID );
//print_rr($groups); //tested and working

$result = $rpcClient->import_survey($SessionKey, $data, "lss", null, $SurveyID);
$rpcClient->release_session_key( $SessionKey );
return $result->status;
$SurveyID = $result;

$result = $rpcClient->activate_survey($SessionKey, $SurveyID);

// release the session key
$rpcClient->release_session_key( $SessionKey );

return $SurveyID;

anyone else who has experience in importing a survey via the remote control?

currently using Version 2.00+ Build 120931


Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!