/**
  * @ignore
  *
  * @param string $faultcode
  * @param string $message
  * @param boolean $json
  * @param string $logpath
  */
 public function __construct($faultcode, $message, $logpath = null)
 {
     $this->setFaultCode($faultcode);
     //$this->faultcode = $faultcode;
     $this->setMessage($message);
     $this->setOutputTitle('Turnitin SDK Exception');
     $logger = new TurnitinLogger($logpath);
     if ($logger) {
         $logger->logError($this->getOutputTitle() . ': ' . $this->getFaultCode() . ' - ' . $this->getMessage());
     }
 }
 public function __doRequest($request, $location, $action, $version, $one_way = null)
 {
     $http_headers = array('Content-type: text/xml;charset="utf-8"', 'Accept: text/xml', 'Cache-Control: no-cache', 'Pragma: no-cache', 'SOAPAction: "' . $action . '"', 'Content-length: ' . strlen($request), 'X-Integration-Version: ' . $this->getIntegrationVersion(), 'X-Plugin-Version: ' . $this->getPluginVersion());
     $location .= !is_null($this->language) ? '?lang=' . $this->language : '';
     $auth_headers[] = 'Source: ' . $this->getIntegrationId();
     $auth_headers[] = 'Authorization: ' . $this->getOAuthHeader($location, $request);
     $curl_headers = array_merge($http_headers, $auth_headers);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $location);
     if (defined('CLI_SCRIPT') && CLI_SCRIPT) {
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($ch, CURLOPT_TIMEOUT, 240);
     } else {
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
         curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
     if (isset($this->sslcertificate) and !empty($this->sslcertificate)) {
         curl_setopt($ch, CURLOPT_CAINFO, $this->sslcertificate);
     }
     if (isset($this->proxyhost) and !empty($this->proxyhost)) {
         curl_setopt($ch, CURLOPT_PROXY, $this->proxyhost . ':' . $this->proxyport);
     }
     if (isset($this->proxyuser) and !empty($this->proxyuser)) {
         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
         curl_setopt($ch, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', $this->proxyuser, $this->proxypassword));
     }
     $this->setHttpHeaders(join(PHP_EOL, $curl_headers));
     if ($this->perflog !== null) {
         $this->perflog->start_timer();
     }
     $result = curl_exec($ch);
     if ($this->perflog !== null) {
         $this->perflog->stop_timer($ch);
     }
     if ($result === false) {
         $logger = new TurnitinLogger($this->logpath);
         if ($logger) {
             $logger->logError('Curl Error: ' . curl_error($ch));
         }
         throw new TurnitinSDKException('Curl Error', curl_error($ch), $this->logpath);
     } else {
         $response = $result;
     }
     $this->setHeaders();
     curl_close($ch);
     return $response;
 }