/**
  *
  * Make http request and get reesponse.
  * @throws OAuthException
  */
 public function DoHttpRequest()
 {
     $ch = curl_init();
     // set URL and other appropriate options
     curl_setopt($ch, CURLOPT_URL, $this->request_url);
     curl_setopt($ch, CURLOPT_VERBOSE, CURL_DEBUG_MODE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->use_ssl);
     if ($this->postfields or $this->method == 'POST') {
         curl_setopt($ch, CURLOPT_POST, true);
     }
     if ($this->postfields) {
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postfields);
     }
     if ($this->headers) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
     }
     if ($this->method and $this->method != 'GET' and $this->method != 'POST') {
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
     /*curl_setopt($ch, CURLOPT_SSLVERSION, 3);*/
     curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
     //--------------------------------
     $this->result = curl_exec($ch);
     //--------------------------------
     if (curl_errno($ch)) {
         $errorCode = 1001;
         $errorMessage = "Error no : " . curl_errno($ch) . "\nError : " . curl_error($ch);
         throw new OAuthException($errorMessage, $errorCode);
     } else {
         $curl_info = curl_getinfo($ch);
         $this->response_header = substr($this->result, 0, $curl_info['header_size']);
         $this->response_body = substr($this->result, $curl_info['header_size']);
         $this->http_code = $curl_info['http_code'];
     }
     // close cURL resource, and free up system resources
     curl_close($ch);
     if (preg_match("/<Error><ErrorCode>/", $this->response_body)) {
         throw new ETWSException($this->response_body, $this->http_code);
     } elseif ($this->http_code < 200 or $this->http_code > 299) {
         $msg_str = $this->response_header;
         if (DEBUG_MODE) {
             ETWSCommon::write_log($this->response_body);
         }
         throw new ETWSException($msg_str, $this->http_code);
     }
 }
Beispiel #2
0
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        exit;
    } catch (Exception $e) {
        echo "***Caught Exception***  \n" . "Error Code \t: " . $e->getCode() . "\n" . "Error Message \t: " . $e->getMessage() . "\n";
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        echo "Exiting...\n";
        exit;
    }
    $endtime = ETWSCommon::get_time();
    $ac_responce_obj = etHttpUtils::GetResponseObject($ac);
    print_r($ac_responce_obj);
    echo "\n totel time for optoin {$choice} : " . ETWSCommon::get_time_diff($starttime, $endtime);
}
/**
 * Get command line input
 * @param string $str
 */
function get_cmdline_input($str)
{
    echo "\nPlease enter * {$str} * : ";
    return trim(fgets(STDIN));
}
/**
 *
 * @method show_menu
 * Provides menu options.
 *