Welcome, Guest
Username: Password: Remember me

TOPIC: Adding a Survey with the RPC

Adding a Survey with the RPC 1 year 11 months ago #87314

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.
The administrator has disabled public write access.

Re: Adding a Survey with the RPC 1 year 11 months ago #87922

  • rawson
  • rawson's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Thank you received: 1
  • Karma: 1
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
The administrator has disabled public write access.

Re: Adding a Survey with the RPC 1 year 11 months ago #87923

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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.242 seconds
Donation Image