- Posts: 40
- 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' ); $iSurveyID_org = 123456; $sNewname = 'Copy of survey 123456'; if(ctype_alnum($iSurveyID_org) && strlen($iSurveyID_org == 6)) { // Valid SID 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 // Copy survey $newSurvey = $myJSONRPCClient->copy_survey($sSessionKey, $iSurveyID_org, $sNewname); // Print results print_r($newSurvey); } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
Array ( [status] => OK [newsid] => 234567)