Home > Backend Development > PHP Tutorial > Sending a post using a browser returns normal data, but using php curl returns garbled characters.

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
3751 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
Latest Articles by Author
Latest Issues
How to post to GraphQL using PHP
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
Upload POST data with files using cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template