标签:extends XML 自己的 als cti const 获得 list number
/*
* 发起GET网络提交
* @params string $url : 网络地址
*/
function https_get($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_HEADER, FALSE) ;
curl_setopt($curl, CURLOPT_TIMEOUT,60);
if (curl_errno($curl)) {
return ‘Errno‘.curl_error($curl);
}
else{$result=curl_exec($curl);}
curl_close($curl);
return $result;
}
/**参数加密
* @param $data
* @param $appSecret
* @return string
*/
function dtk_makeSign($data, $appSecret)
{
ksort($data);
$str = ‘‘;
foreach ($data as $k => $v) {
$str .= ‘&‘ . $k . ‘=‘ . $v;
}
$str = trim($str, ‘&‘);
$sign = strtoupper(md5($str . ‘&key=‘ . $appSecret));
return $sign;
}
<?php
namespace app\api\controller;
use think\facade\Request;
use think\Db;
class Tbk extends Base
{
public function __construct (){
$this->host = ‘https://openapi.dataoke.com/api/goods/get-goods-list‘;
$this->appKey = ‘5d5b9****c103‘;//换成自己的应用的key
$this->appSecret = ‘d7fa1e55d24*********9fc0a6015‘;//换成自己的应用的Secret
}
public function nine9(){
//默认必传参数
$data = [
‘appKey‘ => $this->appKey,
‘version‘ => ‘1‘,
];
//加密的参数
$data[‘sign‘] = dtk_makeSign($data,$this->appSecret);
//拼接请求地址
$url = $this->host .‘?‘. http_build_query($data);
//执行请求获取数据
$output = https_get($url);
echo "<pre>";
var_dump(json_decode($output));
}
}
标签:extends XML 自己的 als cti const 获得 list number
原文地址:https://www.cnblogs.com/wmc1125/p/11385815.html