- 文字教程:在每次请求的请求头中加入‘Basic Authorization’基础认证,其值为:appid + ‘:’ + token 组成字符串,在将这段字符串用base64编码。啥是HTTP基础认证?
- PHP代码教程:
$curl = curl_init();
$header = array(
'Content-Type: application/json',
'Version: 你要请求的接口版本号',
'Authorization: Basic '.base64_encode('你的应用ID:你获取到的令牌'),
);
curl_setopt($curl, CURLOPT_URL, '请求路径');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($curl);
curl_close($curl);
unset($curl);
print_r($response);