Adding a Survey with the RPC

More
4 years 6 months ago #87314 by rbauling0818
rbauling0818 created the topic: Adding a Survey with the RPC
I'm using LimeSurvey Version 2.00+ Build 121024 and I'm having no luck adding a survey with the RPC. I'm putting in the correct parameters as far as I know it is:
$add_survey = $myJSONRPCClient->add_survey($sSessionKey, $iSurveyID, $sSurveyTitle, $sSurveyLanguage, $sformat = 'G');

Then I add a
print_r($add_survey);

Am I doing this correctly? When I load the page I get an Array with faulty parameters and I've tried changing the parameters over and over again.

Please Log in to join the conversation.

More
4 years 5 months ago #87922 by rawson
rawson replied the topic: Adding a Survey with the RPC
Try something like this:
$limesurvey = new jsonRPCClient('http://localhost/limesurvey/index.php/admin/remotecontrol/');
$sessionKey = $limesurvey->get_session_key('adminusername', 'adminpassword');
$survey = $limesurvey->add_survey($sessionKey, null, 'Survey Title', 'en', 'S');
$limesurvey->release_session_key($sessionKey);

passing null as the survey ID will have limesurvey generate one for you.

You will probably need to change the URL to the limesurvey installation (in this case http://localhost/limesurvey) as well as the username and password parameters of the get_session_key function

Please Log in to join the conversation.

More
4 years 5 months ago #87923 by rbauling0818
rbauling0818 replied the topic: Adding a Survey with the RPC
Hmm thank you this seemed to work for me. The thing that I was missing was 'en' I had 'eng' for my language string. Also the survey that gets created is through a form so I had to set a variable for the survey ID because it is associated with a userid.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now