[英]PHP CURL not working with UTF-8 Character
我尝试使用带有PHP CURL请求的api获取蒸汽项,但问题是CURL不支持将UTF-8作为请求。
我的PHP代码
$steam_key = $this->config->item("steam_key");
$name = "★ StatTrak™ Bayonet";
echo $url = "http://api.csgo.steamlytics.xyz/v1/prices/$name?key=$steam_key";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec ($ch);
echo $response;
我没有任何回应。
只需对URL进行编码,然后再将其与cURL一起使用。
使用urlencode
完成此任务:
$steam_key = $this->config->item("steam_key");
$name = urlencode("★ StatTrak™ Bayonet"); //Add function call here
echo $url = "http://api.csgo.steamlytics.xyz/v1/prices/$name?key=$steam_key";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.