Your LimeSurvey version: .5.4.5
Own server or LimeSurvey hosting: Own server (Community)
Survey theme/template: NA
==================
I am writing an integration script that creates survey participants and sends invites whenever a support ticket is closed.
I have access to all of the ticket information fields available to me in a PHP script and I can successfully add participants and send invitations from the script.
The last piece is I want to submit some information from the ticket into question fields in the response by using the participant token.
Example: I have a hidden question called "Ticket ID". I intend to auto-populate this question with the ticket number from my ticket system completely transparently to the end user.
I have figured out how to pass question answers by adding a GET request parameter, but this exposes that information to the end user (this is acceptable, but not ideal)
I think I need to use the
Code:
// Get the API Client Handle
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_RPCURL );
// Authenticate and receive a session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
// Build the participant from ticket data
$participant = array("email"=>$email,"lastname"=>$last,"firstname"=>$first,"language"=>$language,"emailstatus"=>$emailStatus);
// Add single participant to an array of length 1
$participantList = array($participant);
// Add the participant to the survey and save the JSON response to get the tokens out of
$tokens = $myJSONRPCClient->add_participants( $sessionKey, $surveyId, $participantList, $createToken );
// Save some ticket information using the token
// TODO - How do I do this?
// Save $ticketNumber to "Ticket ID" question. I have a already created a URL parameter called 'ticketid' which works. If I can use this parameter directly from the API, that would be awesome.
// Create an array of length 1 using the single returned token.
$tokenIds = array($tokens[0]['tid']);
// Send invites
$tokens = $myJSONRPCClient->add_participants( $sessionKey, $surveyId, $participantList, $createToken );