- Posts: 12
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
<?php define( 'LS_BASEURL', 'https://path/to/limesurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); require_once '../../../../../application/libraries/jsonRPCClient.php'; $iSurveyID = 123456; // 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 ); // Define attributes $aAttributeFields = array(1, 2, 3); // Activate the tokens $tokenActivation = $myJSONRPCClient->activate_tokens($sSessionKey, $iSurveyID, $aAttributeFields); // The returned result if($tokenActivation['status'] == 'OK') { echo 'Tokens created for survey '.$iSurveyID.'.'; } else { echo 'Tokens NOT created for survey '.$iSurveyID.': '.$tokenActivation['status']; } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); ?>