接三方一些总结
方式: 1.证书 (https://www.cnblogs.com/hanling/p/12411318.html) 2.Authentication: Basic Auth
$arr_header[] = "Content-Type:application/json";$arr_header[] = "Authorization:Basic ".base64_encode($username.":".$password);
$arr_header[] = "Accept: application/json";$result = $this->_curl($param, $url, ‘GET‘, $run_time, $arr_header);
public function _curl($data, $url = ‘‘, $method = ‘GET‘, &$run_time = 0, $headers = []) { $start_time = intval(microtime(true) * 1000); $curl = curl_init(); if ($method == ‘POST‘) { curl_setopt($curl, CURLOPT_POST, true); if(!is_array($data)) { curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } else { curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); } } else { $url .= ‘?‘ . http_build_query($data); } if(!empty($headers)) { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $res = curl_exec($curl); $arrRet = json_decode($res, true); curl_close($curl); $end_time = intval(microtime(true) * 1000); $run_time = $end_time - $start_time; return $arrRet;}3.验签
相关推荐
83911535 2020-11-13
曾是土木人 2020-10-31
yegen00 2020-10-21
soralaro 2020-10-11
katanaFlower 2020-09-18
wytzsjzly 2020-08-17
88407710 2020-08-17
ChinaJoeEE 2020-08-16
CyborgLin 2020-08-15
Blueberry 2020-08-15
PinkBean 2020-08-11
katanaFlower 2020-08-03
hunningtu 2020-07-30
阿债的方寸天地 2020-06-28
pingyan 2020-06-25
wytzsjzly 2020-06-25
阳光岛主 2020-06-25
阿债的方寸天地 2020-06-16