- Posts: 12
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Add token by login from other system
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
8 years 5 months ago #127364
by cristinalancioni
Add token by login from other system was created by cristinalancioni
Hello.
I would like to automatically login in my survey.
I have authentication details in browser session (from other program) and I would like automatically add token put code from session to token table and then automatically login.
What can I do?
Thanks in advance.
Cristina.
I would like to automatically login in my survey.
I have authentication details in browser session (from other program) and I would like automatically add token put code from session to token table and then automatically login.
What can I do?
Thanks in advance.
Cristina.
The topic has been locked.
- gabrieljenik
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 272
- Thank you received: 45
8 years 5 months ago #127369
by gabrieljenik
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
Replied by gabrieljenik on topic Add token by login from other system
Hi!
Have you taken a look at the LS API (aka Remote Control 2)?
manual.limesurvey.org/RemoteControl_2_API
api.limesurvey.org/classes/remotecontrol...hod_add_participants
Thanks!
Have you taken a look at the LS API (aka Remote Control 2)?
manual.limesurvey.org/RemoteControl_2_API
api.limesurvey.org/classes/remotecontrol...hod_add_participants
Thanks!
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago #127373
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
Hi,
I tried to do example in manual.limesurvey.org/RemoteControl_2_API
but nothing work: it give me a blank page, like the path http://my_site_path/index.php/admin/remotecontrol
I put the script into my root and name it "test.php" and I change include_once like that: include_once 'third_party/kcfinder/core/autoload.php';
then I change LS_BASEURL, LS_USER, LS_PASSWORD (the admin user that login to admin interface), $survey_id.
why and how can I do?
thanks.
Cristina.
I tried to do example in manual.limesurvey.org/RemoteControl_2_API
but nothing work: it give me a blank page, like the path http://my_site_path/index.php/admin/remotecontrol
I put the script into my root and name it "test.php" and I change include_once like that: include_once 'third_party/kcfinder/core/autoload.php';
then I change LS_BASEURL, LS_USER, LS_PASSWORD (the admin user that login to admin interface), $survey_id.
why and how can I do?
thanks.
Cristina.
The topic has been locked.
- gabrieljenik
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 272
- Thank you received: 45
8 years 5 months ago #127374
by gabrieljenik
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
Replied by gabrieljenik on topic Add token by login from other system
Any error appears?
Have you enabled the API from the general settings?
Have you enabled the API from the general settings?
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago #127375
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
I don't know....
What do I do?
thanks.
Cristina.
What do I do?
thanks.
Cristina.
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago #127376
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
I see this documentation:
manual.limesurvey.org/RemoteControl
but I don't find variable $enableLsrc in any place...
I've limesurvey206plus-build151014
thanks.
but I don't find variable $enableLsrc in any place...
I've limesurvey206plus-build151014
thanks.
The topic has been locked.
- gabrieljenik
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 272
- Thank you received: 45
8 years 5 months ago #127377
by gabrieljenik
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
Replied by gabrieljenik on topic Add token by login from other system
Try in the config.php or in lsrc.config.php files...
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago #127385
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
Hi.
Yes... but I don't have lsrc.config.php file and $enableLsrc there isn't in config.php, nor in all files.....
Is there any other option I can configure and where? Do I have to activate ldap also?
Thanks.
Cristina.
Yes... but I don't have lsrc.config.php file and $enableLsrc there isn't in config.php, nor in all files.....
Is there any other option I can configure and where? Do I have to activate ldap also?
Thanks.
Cristina.
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago #127386
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
Hi.
I found the way to activate rpc: I chose "JSON-RPC" on "interface" global settings in my admin account.
Now the problem is that the following example code doesn't work...
// without composer this line can be used
require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
//include_once 'third_party/kcfinder/core/autoload.php';
define( 'LS_BASEURL', ' sitotretest.intra/index.php '); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'my_admin_user' );
define( 'LS_PASSWORD', 'my_password' );
// the survey to process
$survey_id=999999;
// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\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
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
print_r($groups, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
what can I do?
Thanks.
Cristina
I found the way to activate rpc: I chose "JSON-RPC" on "interface" global settings in my admin account.
Now the problem is that the following example code doesn't work...
// without composer this line can be used
require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
//include_once 'third_party/kcfinder/core/autoload.php';
define( 'LS_BASEURL', ' sitotretest.intra/index.php '); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'my_admin_user' );
define( 'LS_PASSWORD', 'my_password' );
// the survey to process
$survey_id=999999;
// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\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
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
print_r($groups, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
what can I do?
Thanks.
Cristina
The topic has been locked.
- cristinalancioni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
8 years 5 months ago - 8 years 5 months ago #127390
by cristinalancioni
Replied by cristinalancioni on topic Add token by login from other system
Hi.
Now the example work!
I change: require_once 'application/libraries/jsonRPCClient.php';
and : $myJSONRPCClient = new JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
but now I'm trying to use add_participants... but it doesn't work... this is the code:
$participantdata[] = array(
'email' => $email,
'lastname' => $last_name,
'firstname' => $first_name,
'token' => $token
);
$bCreateToken = true;
$token = $myJSONRPCClient->add_participants($sessionKey, $survey_id, $participantData,$bCreateToken);
NOTE: I want to assign a token that I specifiy....
how can I do? which is the problem???
thanks in advance.
Cristina.
Now the example work!
I change: require_once 'application/libraries/jsonRPCClient.php';
and : $myJSONRPCClient = new JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
but now I'm trying to use add_participants... but it doesn't work... this is the code:
$participantdata[] = array(
'email' => $email,
'lastname' => $last_name,
'firstname' => $first_name,
'token' => $token
);
$bCreateToken = true;
$token = $myJSONRPCClient->add_participants($sessionKey, $survey_id, $participantData,$bCreateToken);
NOTE: I want to assign a token that I specifiy....
how can I do? which is the problem???
thanks in advance.
Cristina.
Last edit: 8 years 5 months ago by cristinalancioni.
The topic has been locked.
- essexsteph
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
8 years 4 months ago #128212
by essexsteph
Replied by essexsteph on topic Add token by login from other system
If you're still stuck on this, I'd suggest the error is in your participant data array. As the function name suggests you can more than one participant so you need an array of arrays. For instance my code to add one participant is:
Hope that helps.
Code:
$pData = array('user' => array('firstname' => 'Course', 'lastname' => 'Evaluation')); $myJSONRPCClient = new JsonRPCClient(LS_BASEURL.'/admin/remotecontrol', true); $sessionKey = $myJSONRPCClient -> get_session_key(LS_USER, LS_PASSWORD); $participant = $myJSONRPCClient -> add_participants($sessionKey, EVAL_ID, $pData); $myJSONRPCClient -> release_session_key($sessionKey);
The topic has been locked.