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

stackoverflow 接口调用返回乱码

PHP中文网
Release: 2023-02-28 12:28:01
Original
1874 people have browsed it

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

1796295229-55c47afa34a18_articlex.jpg

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

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

方法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;
}
Copy after login

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


source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template