The LimeSurvey RemoteControl API is a XML/JSON-RPC based web service available in LimeSurvey 2.0 that offers various API functions. The API allows for developers to control specific functionality of LimeSurvey from another application, without having to use the PHP language. However, I will be using PHP and JSON-RPC for my examples in this post.
Note: You must have the RPC interface enabled first! You can enable RPC in Configuration > Global Settings > Interfaces.
In an effort to reduce code, I will be utilizing a light-weight JSON RPC client. The dependency can be required in Composer via:
composer require weberhofer/jsonrpcphp
Now that I have the dependency required, I can begin to write code. The code that follows in this example will download responses for a survey and save them in a file.
// load composer
// LimeSurvey URL, username & password
// survey to download
$survey_id = 123456;
// instantiate a new client
$client = new \org\jsonrpcphp\JsonRPCClient(LS_URL);
// receive session key
$session_key = $client->get_session_key(LS_USER, LS_PASS);
// get all responses
$file = $client->export_responses($session_key, $survey_id, 'csv');
// save responses to file
file_put_contents($survey_id . '.csv', base64_decode($file));
// release the session key
This is just a small example of what can be accomplished with what the API has to offer. This code could be modified to automate downloading several surveys. You can learn much, much more about the RemoteControl API over at LimeSurvey.