接三方一些总结

Posted hanling

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接三方一些总结相关的知识,希望对你有一定的参考价值。

方式:
  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.验签

 

以上是关于接三方一些总结的主要内容,如果未能解决你的问题,请参考以下文章

Facebook第三方登录流程总结

Python之常用第三方库总结

C++ 接配器(Adapter)总结

iOS开发之Runtime常用示例总结

iOS开发之Runtime常用示例总结

Keras一些常用的API总结