Problem using RC/API

  • grisuno
  • grisunos Avatar Autor
  • Besucher
  • Besucher
3 Jahre 11 Monate her - 3 Jahre 11 Monate her #98505 von grisuno
grisuno erstellte das Thema Problem using RC/API
Dear, I have a problem, do not know, if I am very stupid or what, but I can not use the functions invite_participants and add_participants, first describe the problem, I use the function add_participants and adding a participant but in blank, and invite_participants returns [status] => Error : No candidate tokens. Now show the sample code I am using.
error_reporting(-1);
require_once 'some_path_to/jsonRPCClient.php';
 
define( 'LS_BASEURL', 'http://some_url/system/survey/index.php');  // adjust this one to your actual LimeSurvey URL
 
define( 'LS_USER', 'admin' );
 
define( 'LS_PASSWORD', 'some_pass' );
 
// the survey to process
 
$survey_id=421678;
 
// instanciate a new client
 
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
 
// receive session key
 
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
// receive all ids and info of groups belonging to a given survey
 
$addp = $myJSONRPCClient->add_participants(
		$sessionKey, 
		$survey_id,
		array('email'=>'jsalinas@enexum.cl','lastname'=>'Salinas','firstname'=>"Jaime"),TRUE);
$send = $myJSONRPCClient->invite_participants($sessionKey, $survey_id);
$myJSONRPCClient->release_session_key( $sessionKey );	
print_r($addp);
print_r($send);
 
$myJSONRPCClient->release_session_key( $sessionKey );
 


and that return
Array
(
    [email] => 
    [lastname] => 
    [firstname] => 
)
Array
(
    [status] => Error: No candidate tokens
)

many thanks in advance
Letzte Änderung: 3 Jahre 11 Monate her von grisuno.

Bitte Anmelden um der Konversation beizutretten.

  • grisuno
  • grisunos Avatar Autor
  • Besucher
  • Besucher
3 Jahre 11 Monate her #98521 von grisuno
grisuno antwortete auf das Thema: Problem using RC/API
i change this line
$addp = $myJSONRPCClient->add_participants(
				$sessionKey, 
				$survey_id,
				array('email'=>'grisuno@gmail.com','lastname'=>'Uno','firstname'=>"Gris"),TRUE);

by
$addp = $myJSONRPCClient->add_participants(
				$sessionKey, 
				$survey_id,
				json_encode(array('email'=>'grisuno@gmail.com','lastname'=>'Uno','firstname'=>"Gris")),TRUE);

and return
{"email":"grisuno@gmail.com","lastname":"Uno","firstname":"Gris"}
Array
(
    [status] => Error: No candidate tokens
)

please any help me.
thanks

Bitte Anmelden um der Konversation beizutretten.

  • grisuno
  • grisunos Avatar Autor
  • Besucher
  • Besucher
3 Jahre 11 Monate her #98566 von grisuno
grisuno antwortete auf das Thema: Problem using RC/API
I was looking at the file remotecontrol.php and function invite_participants saw that when returns "[status] => Error: No tokens candidate" is not found in the table tokens_{id_survey} invite candidates, so I'm sure add_participants is not add to the new participant to the db, even if the chain returns json data with "new participant" please help me because I do not see it anywhere error.

many thanks
:(

Bitte Anmelden um der Konversation beizutretten.

  • grisuno
  • grisunos Avatar Autor
  • Besucher
  • Besucher
3 Jahre 10 Monate her #98633 von grisuno
grisuno antwortete auf das Thema: Problem using RC/API
Greetings friends! I'm still with the problem, the situation is this;

add_participants function returns to me a json string like
{"email":"grisuno@gmail.com","lastname":"Uno","firstname":"Gris"}
but the participant never add to the table "tokens_{id_survey}"
is therefore why function invite_participants always returns to me
Array
(
    [status] => Error: No candidate tokens
)
please help I'm totally desperate
:(
in advance thank you very much

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 3 Wochen her #109693 von jalpesh
jalpesh antwortete auf das Thema: Problem using RC/API
Did you find a solution??? i have the same problem...

Bitte Anmelden um der Konversation beizutretten.

Mehr
2 Jahre 11 Monate her #110811 von farfadet
farfadet antwortete auf das Thema: Problem using RC/API
Hi there,

I'm also working with the RCPs and had same "Error:No candidate tokens" trying to send invitations (invite_participants) after an add_participants. This was because I was lacking the "emailstatus":"OK" in the participantData.

So either adding this to your participantData in your add_participant or using the function set_participant_properties to modify "emailstatus" to OK should solve this.

By the way, if you want to set your own survey participation tokens and not use the automatic one created by add_participants, you should use :
"createTokenKey":"0" instead of "createTokenKey":"false" which kept overwriting my home made token.

Hope this helps :-)

Bitte Anmelden um der Konversation beizutretten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten