123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- declare (strict_types=1);
- namespace library\lib;
- class expInfo {
-
- private $host = "https://ali-deliver.showapi.com/";
- private $appcode = '';
-
- public function showapiExpInfo($code,$com = 'auto'){
- $querys = "com=" . $com . "&nu=".$code;
- $data = $this->httpGet('showapi_expInfo',$querys);
- return json_decode($data,true);
- }
-
- private function httpGet($url,$query) {
- $headers = array();
- array_push($headers, "Authorization:APPCODE " . $this->appcode);
- $url = $this->host . $url . '?' . $query;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_FAILONERROR, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_HEADER, false);
- if (1 == strpos("$".$this->host, "https://"))
- {
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- }
- $res = curl_exec($curl);
- curl_close($curl);
- return $res;
- }
- function curlPost($url, $post_data = array(), $timeout = 5, $data_type = "") {
-
- if($data_type == 'json'){
- $post_string = json_encode($post_data);
- }elseif($data_type == 'array') {
- $post_string = $post_data;
- }elseif(is_array($post_data)){
- $post_string = http_build_query($post_data, '', '&');
- $post_string = urldecode($post_string);
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- }
|