- Posts: 2
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<?php require_once 'path/to/jsonRPCClient.php'; define( 'LS_BASEURL', 'https://path/to/limeSurvey/'); define( 'LS_USER', 'limesurvey_admin_name' ); define( 'LS_PASSWORD', 'limesurvey_admin_password' ); define( 'LS_DB_HOST', 'localhost' ); define( 'LS_DB_NAME', 'database_name' ); define( 'LS_DB_USER', 'database_user' ); define( 'LS_DB_PASS', 'database_password' ); define( 'LS_DB_TABLEPREFIX', 'lime_' ); // Define some vars $param1Sgq = '111111X22X333'; $param1Answer = $_POST['param1']; $param2Sgq = '111111X22X334'; $param2Answer = $_POST['param2']; $esgq = explode('X', $param1Sgq); $sid = $esgq[0]; if(ctype_alnum($sid) && strlen($sid) == 6) { // Valid SID format // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' ); // Get a session key $sessionKey = $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); // Build an array of response data $aResponseData = array($param1Sgq=>$param1Answer, $param2Sgq=>$param2Answer); // Add a response set $addResponse= $myJSONRPCClient->add_response($sessionKey, $sid, $aResponseData); // You could do something with the response ID here //echo $addResponse; // Release the session key $myJSONRPCClient->release_session_key( $sessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>