Sending a post using a browser returns normal data, but using php curl returns garbled characters.

PHP中文网
Release: 2023-03-01 07:28:02
Original
3708 people have browsed it

Using a browser to send a post returns normal data. Using php curl returns garbled characters

The header is filled correctly
Such garbled characters:�
Is the returned data encrypted?

I figured it out myself. The returned data was compressed by gzip, and curl needs to be decompressed to work properly. Thank you.

Reply content:

The header is filled correctly
Such garbled characters:�
Is the returned data encrypted?

I figured it out myself. The returned data was compressed by gzip, and curl needs to be decompressed to work properly. Thank you.

See what character set is returned, use iconv to convert to your current character set

Add a sentence to CURL:

curl_setopt($ch, CURLOPT_ENCODING, "");
Copy after login

Encoding problem, check what encoding the site you requested uses (such as utf-8/gbk), and unify Next

The above is using a browser to send post return data. Normally using php curl returns garbled content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template