2
我試圖從我的服務器發送一個http請求到另一臺服務器。 我發送請求的URL包含一些utf8字符,例如http://www.aparat.com/etc/api/videoBySearch/text/نوروز。php-curl dosen't在url中支持utf-8
這裏是我的代碼:
const api_adress = 'http://www.aparat.com/etc/api/';
const xml_config = 'http://www.aparat.com/video/video/config/videohash/[ID]/watchtype/site';
public function getDataInArray($JSON_ADRESS)
{
$json = json_decode(file_get_contents(self::api_adress . utf8_encode($JSON_ADRESS)), true);
return ($json != NULL) ? $json : die(NULL);
}
我也曾嘗試PHP捲曲insted的文件-GET-的內容,但我沒有答案。
的可能的複製[文件\ _get \ _contents()打破了UTF-8字符(http://stackoverflow.com/questions/2236668/file-get-contents-breaking-up-utf-8-characters) – ksno
不,它不是重複的。 – Will
我看你已經試過[utf8_encode()](http://php.net/)。該函數從ISO-8859-1轉換爲UTF-8,並且不能在ISO-8859-1中存儲阿拉伯字符。 –