Trying to get API working...

4 years 2 months ago #93558 by miracle
miracle created the topic: Trying to get API working...

We have configured a survey. Every time a user finished a web application, we would like that user to receive an email with a link to that survey. So every time a user finished the application, a new entry for that survey has to be created. From our application I assume I will have to call an LimeSurvey API function to generate a new entry. The user recieves an email with a link including a unique code. We know some things from when the application was used which we would like to show to the user, like date and time the application was used.

To create a new entry for the survey, I think we have to use the add_participants functions. Is that correct?

The documentation is not quite clear on how to add extra data. I see terms like tokens and attributes and I am not completely sure which is which. Can I send that extra info with the add_participants function?

From an example in the documentation, I got something like this:

require_once '../scripts/jsonRPCClient.php';
define( 'LS_BASEURL', ' ');
define( 'LS_USER', 'rpcuser' );
define( 'LS_PASSWORD', 'mypassword' );

$survey_id=374699; // survey ID: not sure where I can find this one

$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );

// add data we want to show to the user when they start the survey
$data = array(
"playdate" => $playdate,
"start_time" => $starttime,
"end_time" => $endtime,
"playlength" => $playlength,
"score" => $score
$reply = $myJSONRPCClient->add_participants( $sessionKey, $survey_id, $data );

$myJSONRPCClient->release_session_key( $sessionKey );

// generate survey URL to send in email to user
$url = " " . $reply[ "token" ];

Is this correct?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now