Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all articles
Browse latest Browse all 17529

API: Invite participants to a survey - by: jltrussart11

$
0
0
Hi,


This php json script works well to add a participant to the survey 318848.
I'm trying to automatically send the invitation at the end.
Any idea why this routine does'nt work?

Thanks for your precious help!



require_once 'application/libraries/jsonRPCClient.php';

define( 'LS_BASEURL', ' www.vecteursleviers.com/conseil ');
define( 'LS_USER', '***' );
define( 'LS_PASSWORD', '***' );
define( 'LS_DB_HOST', 'localhost' );
define( 'LS_DB_NAME', 'limesurvey' );
define( 'LS_DB_USER', 'root' );
define( 'LS_DB_PASS', '' );
define( 'LS_DB_TABLEPREFIX', 'lime_' );

$iSurveyID = 318848;
$token = 'ABCDE';
$email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
$LastNameAPI = 'Nom famille' ;
$FirstNameAPI = 'Prenom' ;


// Instantiate a new RPC client
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/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"=>'fr',"emailstatus"=>"OK");
$aParticipantData=array($tokenParams);
$bCreateToken = true;

// 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].'</li>'
.'<li>Token - '.$newToken[0].'</li>'
.'</ul>';

// Send Invitations routine: invite_participants(string $sSessionKey, int $iSurveyID, array $aTokenIds = false, bool $bEmail = true) : array
invite_participants(string $sSessionKey, int $iSurveyID, array $aTokenIds = $newToken, bool $bEmail = true) : array

// Release the session key
$myJSONRPCClient->release_session_key( $sSessionKey );
?>

Viewing all articles
Browse latest Browse all 17529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>