- Posts: 3
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/limeSurvey'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); $iQuestionID = 123; if(ctype_alnum($iQuestionID)) { // Valid QID format // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' ); // Get a session key $sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); if(is_array($sSessionKey)) { // Invalid session echo $sSessionKey['status']; } else if($sSessionKey) { // Valid session $questionProperties = $myJSONRPCClient->get_question_properties($sSessionKey, $iQuestionID); foreach($questionProperties['answeroptions'] as $key => $value) { foreach($value as $key => $value) { echo $key . ' => ' . $value . '<br />'; } echo '<br /><br />'; } } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>