请求域名对应host添加到请求头中
<?php
$host = gethostbyname('kingcard.dgunicom.com');
curl_setopt($ch, CRULOPT_HTTPHEADER, ['Host: '.$host]);
?>
$ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, 'https://kingcard.dgunicom.com/dgZop/api/numSelect');
curl_setopt($ch, CURLOPT_URL, 'https://211.95.193.53/dgZop/api/numSelect');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$headers = array();
$headers[] = 'Host: kingcard.dgunicom.com';
$headers[] = 'Content-Type: application/json';
$headers[] = 'Expect:';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $result;