- Posts: 173
- Thank you received: 27
Ask the community, share ideas, and connect with other LimeSurvey users!
echo 'Error - no invitation sent!';
print_r($newMail);
echo $newMail;
<?php define( 'LS_BASEURL', 'https://pathTo/limesurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', '****' ); require_once 'relativePathTo/application/libraries/jsonRPCClient.php'; $iSurveyID = 885886; $token = 'ABCDE'; $email = 'example@example.com'; $LastNameAPI = 'Firstname' ; $FirstNameAPI = 'Lastname' ; // 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 the token params $tokenParams = array("email"=>$email,"lastname"=>$LastNameAPI,"firstname"=>$FirstNameAPI,"token"=>$token,"language"=>'en',"emailstatus"=>"OK"); $aParticipantData=array($tokenParams); $bCreateToken = false; // Create the tokens $newToken = $myJSONRPCClient->add_participants( $sSessionKey, $iSurveyID, $aParticipantData, $bCreateToken); // Print returned results echo '<hr><br><h1>Limesurvey</h1><br>New token created in survey '.$iSurveyID.':' .'<ul>' .'<li>TID - '.$newToken[0]['tid'].'</li>' .'<li>Token - '.$newToken[0]['token'].'</li>' .'</ul>'; // Send an invitation to the created token $tokenIDs = array($newToken[0]['tid']); $newMail = $myJSONRPCClient->invite_participants($sSessionKey, $iSurveyID, $tokenIDs, true); // Print returned results if($newMail[$newToken[0]['tid']]['status'] == 'OK') { echo 'Invitation sent to:' .'<ul>' .'<li>Name - '.$newMail[$newToken[0]['tid']]['name'].'</li>' .'<li>Email - '.$newMail[$newToken[0]['tid']]['email'].'</li>' .'</ul>'; } else { echo 'Error - no invitation sent!'; } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); ?>
$bCreateToken = false;
$bCreateToken = true;
We are using that API function regularly. It must have been a temporary issue. I just tested that function at the latest 6.x version and it is working fine there.So is this a bug in 2.6.4 as the invite_participants is not working in that version it seems