API, PHP - add_participants now working

More
2 years 2 months ago #125812 by essexsteph
essexsteph created the topic: API, PHP - add_participants now working
Hi, just getting going using Limesurvey, but hoping somebody may be able to help with an API question. The following PHP isn't working, i.e. a new entry isn't made in the token table. Other calls to the API (list_groups, export_responses, list_participants) are working fine so any suggestions welcomed.

Thanks
$pData = array('email'=>'me@nowhere.com', 'firstname'=>'James','lastname'=>'Bond');
$pData = json_encode($pData);
$myJSONRPCClient = new JsonRPCClient(LS_BASEURL.'/admin/remotecontrol');
$sessionKey= $myJSONRPCClient -> get_session_key( LS_USER, LS_PASSWORD );
$participant = $myJSONRPCClient -> add_participants($sessionKey, EVAL_ID, $pData, TRUE);
$myJSONRPCClient -> release_session_key( $sessionKey );

Please Log in to join the conversation.

More
2 years 2 months ago #125847 by essexsteph
essexsteph replied the topic: API, PHP - add_participants now working
OK, I had another bash and found the solution, for completeness here's what worked for me:
$pData = array('user' => array('firstname' => 'Dummy', 'lastname'  => 'Dummy', 'email' => 'me@nowhere.com'));
$myJSONRPCClient = new JsonRPCClient(LS_BASEURL.'/admin/remotecontrol');
$sessionKey= $myJSONRPCClient -> get_session_key(LS_USER, LS_PASSWORD);
$participant = $myJSONRPCClient -> add_participants($sessionKey, EVAL_ID, $pData);
$myJSONRPCClient -> release_session_key($sessionKey);

Please Log in to join the conversation.

More
2 years 2 months ago #125851 by DenisChenu
DenisChenu replied the topic: API, PHP - add_participants now working
Oh yes , ytou don't have to json encode the data. You must NOT :).

Good job :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!