PHP code example of meritoo / limesurvey-api-client

1. Go to this page and download the library: Download meritoo/limesurvey-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

meritoo / limesurvey-api-client example snippets


    use Meritoo\LimeSurvey\ApiClient\Client\Client;
    use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration;
    use Meritoo\LimeSurvey\ApiClient\Type\MethodType;

    /*
     * Prepare configuration of connection and client of the API
     */
    $configuration = new ConnectionConfiguration('http://test.com', 'test', 'test');
    $client = new Client($configuration);
    

    /*
     * Run lt = $client->run(MethodType::LIST_SURVEYS);
    

    /*
     * ...and grab data from the result
     */
    $data = $result->getData();
    

use Meritoo\LimeSurvey\ApiClient\Client\Client;
use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;

/*
 * Prepare configuration of connection and client of the API
 */
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test');
$client = new Client($configuration);

/*
 * Run 

// Add a response to the survey responses collection
MethodType::ADD_RESPONSE;

// The IDs and properties of token/participants of a survey
MethodType::LIST_PARTICIPANTS;

// List the surveys belonging to a user
MethodType::LIST_SURVEYS;

$client->run(MethodType::GET_PARTICIPANT_PROPERTIES);

use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration;
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test', true);

$configuration->setDebugMode(true);

$debugMode = $configuration->isDebugModeOn();

use Meritoo\LimeSurvey\ApiClient\Result\Result;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;

$result = new Result(MethodType::LIST_SURVEYS, []);
$isEmpty = $result->isEmpty();

var_dump($isEmpty); // bool(true)

class Meritoo\Common\Collection\Collection#565 (1) {
  private $elements =>
  array(2) {
    [0] =>
    class Meritoo\LimeSurvey\ApiClient\Result\Item\Survey#564 (5) {
      private $id =>
      int(456)
      private $title =>
      string(12) "Another Test"
      private $expiresAt =>
      NULL
      private $active =>
      bool(true)
    }
    [1] =>
    class Meritoo\LimeSurvey\ApiClient\Result\Item\Survey#564 (5) {
      private $id =>
      int(456)
      private $title =>
      string(12) "Another Test"
      private $expiresAt =>
      NULL
      private $active =>
      bool(true)
    }
  }
}

class Meritoo\LimeSurvey\ApiClient\Result\Item\Participant#701 (17) {
  private $id =>
  int(123)
  private $participantId =>
  int(456)
  private $mpId =>
  NULL
  private $firstName =>
  string(5) "Lorem"
  private $lastName =>
  string(5) "Ipsum"
  (...)
}

array(2) {
  [0] =>
  array(5) {
    'sid' =>
    string(3) "123"
    'surveyls_title' =>
    string(4) "Test"
    'startdate' =>
    NULL
    'expires' =>
    string(19) "2017-09-19 13:02:41"
    'active' =>
    string(1) "N"
  }
  [1] =>
  array(5) {
    'sid' =>
    string(3) "456"
    'surveyls_title' =>
    string(12) "Another Test"
    'startdate' =>
    string(19) "2017-09-19 13:02:41"
    'expires' =>
    NULL
    'active' =>
    string(1) "Y"
  }
}