From c298d711bfde0f6088d442c8a1849a0a8661b38f Mon Sep 17 00:00:00 2001 From: wyongk <937888580@qq.com> Date: Fri, 18 Dec 2020 21:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extends/realname/verify.php | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 extends/realname/verify.php diff --git a/extends/realname/verify.php b/extends/realname/verify.php new file mode 100644 index 0000000..3329325 --- /dev/null +++ b/extends/realname/verify.php @@ -0,0 +1,75 @@ + "", + "userName" => "", + +); + +$header = array(); +$header[] = "apicode:".$apicode; +$header[] = "content-type:application/json"; +$header[] = "Content-Type:application/json"; + + +$content = linkcurl($url,$method,$params,$header); +$result = json_decode($content,true); +if($result){ + if($result['error_code']=='0'){ + print_r($result); + }else{ + echo $result['error_code'].":".$result['reason']; + } +}else{ + echo "请求失败"; +} + +/** + * 请求接口返回内容 + * @param string $url [请求的URL地址] + * @param string $params [请求的参数] + * @param int $ipost [是否采用POST形式] + * @return string + */ +function linkcurl($url,$method,$params=false,$header=false){ + $httpInfo = array(); + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); + curl_setopt($ch, CURLOPT_FAILONERROR, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + if (1 == strpos("$".$url, "https://")) + { + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + } + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); + curl_setopt( $ch, CURLOPT_TIMEOUT , 60); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + + if($method == "POST" ){ + curl_setopt( $ch , CURLOPT_POST , true ); + curl_setopt( $ch , CURLOPT_POSTFIELDS, json_encode($params) ); + }else if($params){ + curl_setopt( $ch , CURLOPT_URL , $url.'?'.http_build_query($params) ); + } + $response = curl_exec( $ch ); + if ($response === FALSE) { + //echo "cURL Error: " . curl_error($ch); + return false; + } + $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE ); + $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) ); + curl_close( $ch ); + return $response; +} \ No newline at end of file