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

API: add_participants - by: tpartner

$
0
0
I'm no API expert but something like this works for me:

<?php
 
	require_once 'jsonRPCClient.php';
 
	define( 'LS_BASEURL', 'http://pathTo/limeSurvey/');
	define( 'LS_USER', 'adminName' );
	define( 'LS_PASSWORD', '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';
 
 
	// 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"=>"example@example.com","lastname"=>"LastName","firstname"=>"FirstName","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 'New token created in survey '.$iSurveyID.':'
		.'<ul>'
		.'<li>TID - '.$newToken[0]['tid'].'</li>'
		.'<li>Token - '.$newToken[0]['token'].'</li>'
		.'</ul>';
 
	// 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>