title: Five9's API: How to pull reports using SOAP API and Basic Authentication
body: <p>We are trying to access data from Five9's server using there reporting API. We have written code below but are not getting any results. To me it looks like issue is with the Authentication to Five9's server. Please check help us understand how we can pull data for a specific campaign on regular interval of time and store it in out Data Warehouse.</p>
  
  <pre><code>&lt;?php
  $soapUser = "USERNAME";  //  username
  $soapPassword = "DEMOPASSWORD"; // password
  
  $soap_options   = array( 'login' =&gt; $soapUser, 'password' =&gt; $soapPassword );
  $auth_details   = base64_encode($soapUser.":".$soapPassword);
  
  $client = new SoapClient("https://api.five9.com/wsadmin/v2/AdminWebService?wsdl",       $soap_options);
  $header = new SoapHeader("https://api.five9.com/wsadmin/v2/AdminWebService/getCallLogReport", "authentication", "Basic $auth_details"); 
  //echo "Response:\n" . $client-&gt;__getLastResponse() . "\n";
  $client-&gt;__setSoapHeaders($header);
  
  $xml_data = '&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://service.admin.ws.five9.com/v2/AdminWebService/getCallLogReport"&gt;
  &lt;soapenv:Header/&gt;
  &lt;soapenv:Body&gt;
    &lt;v2:getCallLogReport&gt;
          &lt;campaigns&gt;Campaign1&lt;/campaigns&gt;
    &lt;/v2:getCallLogReport&gt;
  &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;';
  
  echo $result = $client-&gt;getCallLogReport($xml_data,   "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl", "https://api.five9.com/wsadmin/v2/AdminWebService/getCallLogReport",0); 
  
  
  ?&gt;  
  </code></pre>
  
  <p>Sample XML </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:v2="http://service.admin.ws.five9.com/v2/"&gt;
  &lt;soapenv:Header/&gt;
  &lt;soapenv:Body&gt;
    &lt;v2:getCallLogReport&gt;
       &lt;!--Optional:--&gt;
       &lt;time&gt;
          &lt;!--Optional:--&gt;
          &lt;end&gt;?&lt;/end&gt;
          &lt;!--Optional:--&gt;
          &lt;start&gt;?&lt;/start&gt;
       &lt;/time&gt;
       &lt;!--Optional:--&gt;
       &lt;criteria&gt;
          &lt;!--Optional:--&gt;
          &lt;ANI&gt;?&lt;/ANI&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;agents&gt;?&lt;/agents&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;callTypes&gt;?&lt;/callTypes&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;campaigns&gt;?&lt;/campaigns&gt;
          &lt;!--Optional:--&gt;
          &lt;DNIS&gt;?&lt;/DNIS&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;dispositions&gt;?&lt;/dispositions&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;lists&gt;?&lt;/lists&gt;
          &lt;!--Zero or more repetitions:--&gt;
          &lt;skillGroups&gt;?&lt;/skillGroups&gt;
       &lt;/criteria&gt;
    &lt;/v2:getCallLogReport&gt;
    &lt;/soapenv:Body&gt;
   &lt;/soapenv:Envelope&gt;
  </code></pre>