如何使用 PHP 中的 curl 从 "unicode domain name" 获得响应?
How to get response from "unicode domain name" with curl in PHP?
我想获取具有 unicode 名称 (http://خبر.com) 的站点的内容。我尝试了以下代码。
$site = "https://خبر.com/";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $site,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded',),
));
$response = curl_exec($curl);
curl_close($curl);
还有这个片段
$response = file_get_contents($site);
我也试图获取网站的IP,但我不能。
我尝试了其他 Unicode 域名,但问题依然存在。
英文域名正确加载。
将您的 Unicode 域名解析为 ASCII
解析后应该可以正常工作。
我想获取具有 unicode 名称 (http://خبر.com) 的站点的内容。我尝试了以下代码。
$site = "https://خبر.com/";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $site,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded',),
));
$response = curl_exec($curl);
curl_close($curl);
还有这个片段
$response = file_get_contents($site);
我也试图获取网站的IP,但我不能。 我尝试了其他 Unicode 域名,但问题依然存在。 英文域名正确加载。
解析后应该可以正常工作。