Home >Backend Development >PHP Tutorial >stackoverflow 接口调用返回乱码

stackoverflow 接口调用返回乱码

PHP中文网
PHP中文网Original
2017-04-27 10:54:391883browse

沒乱码~ 和网页直接打开一样的.

1796295229-55c47afa34a18_articlex.jpg

哦!可能是gzip编码的问题
方法1:

$data = file_get_contents("compress.zlib://".$url);

方法2:curl

function curl_get($url, $gzip=false){ $curl = curl_init($url);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); if($gzip) curl_setopt($curl, CURLOPT_ENCODING, "gzip"); // 关键在这里 $content = curl_exec($curl);
 curl_close($curl); return $content;
}

方法3:gzip函数解压缩自己去查手冊


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn