- Posts: 9
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
list_participants(string $sSessionKey,integer $iSurveyID,integer $iStart,integer $iLimit = 10,boolean $bUnused = false,boolean|array $aAttributes = false,array $aConditions = array()): array
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/limeSurvey'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); $iSurveyID = 123456; if(ctype_alnum($iSurveyID) && (strlen($iSurveyID) == 5 || strlen($iSurveyID) == 6)) { // Valid SID format // 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 ); if(is_array($sSessionKey)) { // Invalid session echo $sSessionKey['status']; } else if($sSessionKey) { // Valid session // Define the additional attributes to be returned $aAttributes = array('attribute_1', 'attribute_2'); // Define filters for participants $aConditions = array('lastname'=>'Doe', 'attribute_1'=>'xyz'); // Get the filtered participants $participants = $myJSONRPCClient->list_participants($sSessionKey, $iSurveyID, 0, 10, false, $aAttributes, $aConditions); // Print the results echo '<ul>'; foreach($participants as $key => $value) { echo '<li>'; print_r($value); echo '</li>'; } echo '</ul>'; } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
1. wiki and code can be improved by user …TonyMonast wrote: There is no indication in the documentation that the conditions argument is an associative array (arrays with named keys). It would be relevant to mention it.