簡體   English   中英

PHP CURL無法使用UTF-8字符

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM