- Posts: 166
- Thank you received: 26
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
API: Invite participants to a survey
- davebostockgmail
- Offline
- Elite Member
Less
More
5 years 8 months ago #171451
by davebostockgmail
Replied by davebostockgmail on topic API: Invite participants to a survey
Hi Tony
I know this is a year old ... I have been trying this script as we now have a need to do this and it creates the entry into the token field but then refuses to send the email ... any thoughts?
Using 2.6.4 lts
Any hints or advice most welcome
Dave
I know this is a year old ... I have been trying this script as we now have a need to do this and it creates the entry into the token field but then refuses to send the email ... any thoughts?
Using 2.6.4 lts
Any hints or advice most welcome
Dave
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
5 years 8 months ago #171465
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic API: Invite participants to a survey
Can you send invitations through the LS GUI?
What is returned by $newMail?
If you see the error message, try replacing
with:
or
What is returned by $newMail?
If you see the error message, try replacing
Code:
echo 'Error - no invitation sent!';
with:
Code:
print_r($newMail);
or
Code:
echo $newMail;
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- davebostockgmail
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
5 years 8 months ago - 5 years 8 months ago #171480
by davebostockgmail
Replied by davebostockgmail on topic API: Invite participants to a survey
So I did that and this is what I get as an output
New token created in survey 146297:
TID - 23
Token - B4ULIxdu2CpvDi7
Array ( [23] => Array ( [name] => Test Drive Customer
New token created in survey 146297:
TID - 23
Token - B4ULIxdu2CpvDi7
Array ( [23] => Array ( [name] => Test Drive Customer
Last edit: 5 years 8 months ago by davebostockgmail.
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
5 years 8 months ago #171501
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic API: Invite participants to a survey
Sorry Dave, I don't know why that's not working. I resurrected an old 2.6.4 version and I get the same result. Maybe a bug in that version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: davebostockgmail
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 8 months ago #171508
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic API: Invite participants to a survey
Maybe you can try to replace
github.com/LimeSurvey/LimeSurvey/blob/2....tecontrol_handle.php
(keep same major version)
Without any warantee
(keep same major version)
Without any warantee
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- davebostockgmail
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
5 years 8 months ago #171516
by davebostockgmail
Replied by davebostockgmail on topic API: Invite participants to a survey
Thank you for your suggestion Denis
Unfortunately still not working.
Thanks
Dave
Unfortunately still not working.
Thanks
Dave
The topic has been locked.
- davebostockgmail
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
5 years 8 months ago #171517
by davebostockgmail
Replied by davebostockgmail on topic API: Invite participants to a survey
Thanks for trying ... I will install a 3.xxx version and try with that ... we need to upgrade anyway ... so I guess this forces our hand.
Will this script work for a 3.xxx version?
Cheers
Dave
Will this script work for a 3.xxx version?
Cheers
Dave
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
5 years 8 months ago - 5 years 8 months ago #171537
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic API: Invite participants to a survey
Using version 3.13.2, this will create a token defined by $token and send the invitation to that token:
If you want to generate a random token value instead of defining it, change this:
To this:
Code:
<?php define( 'LS_BASEURL', 'http://pathTo/limesurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', '****' ); require_once 'relativePathTo/application/libraries/jsonRPCClient.php'; $iSurveyID = 885886; $token = 'ABCDE'; $email = 'example@example.com'; $LastNameAPI = 'Firstname' ; $FirstNameAPI = 'Lastname' ; // 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"=>$email,"lastname"=>$LastNameAPI,"firstname"=>$FirstNameAPI,"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 '<hr><br><h1>Limesurvey</h1><br>New token created in survey '.$iSurveyID.':' .'<ul>' .'<li>TID - '.$newToken[0]['tid'].'</li>' .'<li>Token - '.$newToken[0]['token'].'</li>' .'</ul>'; // Send an invitation to the created token $tokenIDs = array($newToken[0]['tid']); $newMail = $myJSONRPCClient->invite_participants($sSessionKey, $iSurveyID, $tokenIDs, true); // Print returned results if($newMail[$newToken[0]['tid']]['status'] == 'OK') { echo 'Invitation sent to:' .'<ul>' .'<li>Name - '.$newMail[$newToken[0]['tid']]['name'].'</li>' .'<li>Email - '.$newMail[$newToken[0]['tid']]['email'].'</li>' .'</ul>'; } else { echo 'Error - no invitation sent!'; } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); ?>
If you want to generate a random token value instead of defining it, change this:
Code:
$bCreateToken = false;
To this:
Code:
$bCreateToken = true;
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 8 months ago by tpartner.
The topic has been locked.
- solte98
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 0
5 years 7 months ago #173752
by solte98
Replied by solte98 on topic API: Invite participants to a survey
So is this a bug in 2.6.4 as the invite_participants is not working in that version it seems
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
1 month 1 week ago #258245
by Mazi
A better approach for fully automating invitation sending is using a cronjob script .
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic API: Invite participants to a survey
We are using that API function regularly. It must have been a temporary issue. I just tested that function at the latest 6.x version and it is working fine there.So is this a bug in 2.6.4 as the invite_participants is not working in that version it seems
A better approach for fully automating invitation sending is using a cronjob script .
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.