API: add_participants

Mehr
3 Jahre 1 Monat her #149674 von jltrussart11
API: add_participants wurde erstellt von jltrussart11
]Hi,

I can't manage the add_participant routine to works for a given survey. Anyone have an idea about it?

Thanks in advance for your precious help!

<?php
 
/* * * * * * * * * * * * * * * * * * * * * * 
 * Start Edit
 * * * * * * * * * * * * * * * * * * * * * */
 
define( 'LS_BASEURL', 'http://www.vecteursleviers.com/conseil' ); // if subbfolder => http://localhost/MyFolder
define( 'LS_USER', '***' ); 
define( 'LS_PASSWORD', '***' ); 
 
$iSurveyId = 318848; // survey ID
$sid = 318848;
 
/* * * * * * * * * * * * * * * * * * * * * *
 * End Edit
 * * * * * * * * * * * * * * * * * * * * * */
 
/* using LimeSurvey (LS) RemoteControly API version 2's JSON-RPC method */
include "application/libraries/jsonRPCClient.php";
 
/* instantiate a new client */
$lsJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );
 
/* receive session key */
$sessionKey = $lsJSONRPCClient->get_session_key(LS_USER, LS_PASSWORD);
 
/* receive all ids and info of query belonging to a given survey */
$properties  = array('template','datecreated','showwelcome','bounce_email');
$result = $lsJSONRPCClient->call('get_survey_properties', array($sessionKey,$iSurveyId,$properties));
 
/*  output */
print_r($result, null );
 
/* Code from http://code.uoa.gr/p/limesurvey/test_scenarios.php */
 
	/* Participants Data */
	$aParticipantData = array(
			'user3'=>array('firstname'=>'Christopher',
					'lastname'=>'hitchens',
					'email'=>'christopher@example.com',
					'language'=>'en',
					'emailstatus'=>'ok'),
			);
	/* Add particpants */
			$result = $client->call('add_participants', array($sessionkey,$sid,$aParticipantData));
 
	/*List participants */
	$result = $client->call('list_participants', array($sessionkey,$sid));
 
	/* End code from http://code.uoa.gr/p/limesurvey/test_scenarios.php */
 
/* release the session key */
$lsJSONRPCClient->release_session_key($sessionKey);
 
?>

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
3 Jahre 1 Monat her #149678 von tpartner
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 );
?>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Folgende Benutzer bedankten sich: jltrussart11

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Jahre 1 Monat her #149685 von jltrussart11
Thanks a lot i get it to works with you precious help!

have a nice day!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Jahre 2 Tage her #152295 von Mazi
Mazi antwortete auf API: add_participants

jltrussart11 schrieb: ]Hi,

I can't manage the add_participant routine to works for a given survey. Anyone have an idea about it?

Thanks in advance for your precious help!

Could be the trailing "," at the end of this line:
'emailstatus'=>'ok'),

If you have fixed your issue, please always post the updated, correct code for others.

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Jahre 2 Tage her #152317 von jltrussart11
Thanks for the reminder. Tparner code works like a charm!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha