i am trying to use the export_statistics api function in php.
if i use the function and pass the id of a survey that has no Responses(no one has taken the survey) then everything works as expected and i get a string wich i use to create a pdf file.
as soon as i try to do the same thing with a survey where there are responses i get the following error:
Code:
Fatal error: Uncaught Exception: Request error: attribute "Response_527793.527793X119X960962 is not defined. in C:\xampp\htdocs\JsonRPCClient.php:161 Stack trace: #0 C:\xampp\htdocs\auswertung.php(28): jsonRPCClient->__call('export_statisti...', Array) #1 {main} thrown in C:\xampp\htdocs\JsonRPCClient.php on line 161
LimeSurvey version: 4.3.23
Php version: 7.4.1
any ideas on what could cause this error would be greatly appreciated
thanks in advance N.M
Last edit: 5 years 10 months ago by NoahMa. Reason: added version numbers
...
require_once 'jsonrpcphp/JsonRPCClient.php';
define( 'LS_BASEURL', 'https://www.myServer.de/limesurvey'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'myUser' );
define( 'LS_PASSWORD', 'myPassword' );
// the survey to process
$survey_id=886223;
// instantiate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
if(is_array($sessionKey))
{
header("Content-type: application/json");
echo json_encode($sessionKey);
echo '<br />This is another test with sesssion key.<br />';
die();
}
else if($sessionKey) // Is a valid session
{
/* Get the responses */
$sResult = $myJSONRPCClient-> export_statistics($sessionKey,$survey_id,"pdf");
$sResult = base64_decode($sResult);
file_put_contents("survey.pdf", $sResult);
}
// Release the session key
$myJSONRPCClient->release_session_key( $sSessionKey );
...
More or less the only difference is that there is a variable $survey_id.
And I get a nice pdf.
So I don't exactly know why your code throws an error.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Thank you for the quick reply,
I used your code and got the same error.
So I suspect there is something other than the code that's not working correctly