0 Replies Latest reply: Aug 15, 2017 6:04 AM by ryan cooke RSS

    Php Qlik ticket request

    ryan cooke

      I've trying to do a php qlik ticket request.

      FIrst I had local ssl certificate propblems but then i followed steps to set the windows env var to allow all and then the error went away but with the following all i get is an empty string response.

      Any Idea's why?

       

      <?php
      
      
      //URL of the server
      $QRSurl = "https://ip:443/dev-test/";
      
      
      //Path to call (with xrfkey parameter added)
      $xrf      = 'aaaaaaaaaaaaaaaa';
      $endpoint = "?xrfkey={$xrf}";
      
      
      //Location of QRS client certificate
      $cert_file = "C:\inetpub\wwwroot\lmc\dependancies\http\login\dependancies\client.pem";
      $keyFile   = "C:\inetpub\wwwroot\lmc\dependancies\http\login\dependancies\client_key.pem";
      
      
      $cert_password = 'dev';
      //Set up the required headers
      $headers = array(
          'Accept: application/json',
          'Content-Type: application/json',
          'x-qlik-xrfkey: {$xrf}',
          'X-Qlik-User: UserDirectory=UserDir;UserId=client1@example.com'
      );
      
      
      //Create Connection using Curl
      $ch = curl_init($QRSurl . $endpoint);
      
      
      echo $QRSurl . $endpoint . '<br>';
      echo '2<br>';
      
      
      $options = array(
          CURLOPT_SSL_VERIFYPEER => false,
          CURLOPT_HTTPHEADER     => $headers,
          CURLOPT_SSLCERT        => $cert_file,
          CURLOPT_SSLCERTPASSWD  => $cert_password,
          CURLOPT_SSLKEY         => $keyFile,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_SSL_VERIFYPEER => false,
          CURLOPT_SSL_VERIFYHOST => false,
          CURLOPT_PROXY          => true
      );
      
      
      curl_setopt_array($ch , $options);
      
      
      //Execute and print response
      echo '3<br>';
      $data = curl_exec($ch);
      
      
      if ($errno = curl_errno($ch))
      {
          $error_message = curl_strerror($errno);
          echo "cURL error ({$errno}):\n {$error_message}";
      }
      
      
      var_dump($data);