- Posts: 14233
- Thank you received: 4340
Ask the community, share ideas, and connect with other LimeSurvey users!
// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
include_once 'vendor/autoload.php';
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient(LS_BASEURL . '/admin/remotecontrol');
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient(LS_BASEURL . '/index.php/admin/remotecontrol');
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/LimeSurvey'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); //$iSurveyID = $_GET['surveyID']; $iSurveyID = 885886; 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 $surveyProperties = $myJSONRPCClient->get_survey_properties($sSessionKey, $iSurveyID); foreach($surveyProperties as $key => $value) { echo $key . ' => ' . $value . '<br />'; } } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
<?php require_once 'JsonRPCClient.php'; define('LS_BASEURL', 'https://www.fnak.fr/limesurvey'); // adjust this one to your actual LimeSurvey URL define('LS_USER', 'user'); define('LS_PASSWORD', 'password'); //$iSurveyID = $_GET['surveyID']; $iSurveyID = 616685; echo '<pre>'; if (ctype_alnum($iSurveyID) && (strlen($iSurveyID) == 5 || strlen($iSurveyID) == 6)) { // Valid SID format // Instantiate a new RPC client $myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient(LS_BASEURL . '/index.php/admin/remotecontrol'); var_dump($myJSONRPCClient); // Get a session key $sSessionKey = $myJSONRPCClient->get_session_key(LS_USER, LS_PASSWORD); if (is_array($sSessionKey)) { // Invalid session echo $sSessionKey['status']; } elseif ($sSessionKey) { // Valid session $surveyProperties = $myJSONRPCClient->get_survey_properties($sSessionKey, $iSurveyID); foreach ($surveyProperties as $key => $value) { echo $key . ' => ' . $value . '<br />'; } } // Release the session key $myJSONRPCClient->release_session_key($sSessionKey); } else { // Invalid SID format die('Invalid format!'); } echo '</pre>';
object(org\jsonrpcphp\JsonRPCClient)#1 (6) { ["debug":"org\jsonrpcphp\JsonRPCClient":private]=> bool(false) ["url":"org\jsonrpcphp\JsonRPCClient":private]=> string(60) "https://www.fnak.fr/limesurvey/index.php/admin/remotecontrol" ["id":"org\jsonrpcphp\JsonRPCClient":private]=> int(1) ["notification":"org\jsonrpcphp\JsonRPCClient":private]=> bool(false) ["enableCurl":"org\jsonrpcphp\JsonRPCClient":private]=> bool(true) ["proxy"]=> string(0) "" }
new \org\jsonrpcphp\JsonRPCClient
new JsonRPCClient(...