结果:

Home  >  Article  >  Backend Development  >  Use curl to send post request, but prompt 302 FOUND

Use curl to send post request, but prompt 302 FOUND

WBOY
WBOYOriginal
2016-08-18 09:16:101985browse

Code:
Use curl to send post request, but prompt 302 FOUND
Result:
Use curl to send post request, but prompt 302 FOUND
Please give me more advice!

Reply content:

Code:
Use curl to send post request, but prompt 302 FOUND
Result:
Use curl to send post request, but prompt 302 FOUND
Please give me more advice!

302 is redirection. You have not set up automatic redirection. Just set it up.

<code>curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, true);</code>

There’s nothing to say, it’s just a 302 redirect, which may prevent access from external links. Or maybe you didn't capture the real address.

Set CURLOPT_FOLLOWLOCATION to false and try it

<code>curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); </code>

You can capture the packet first to see if there is location information in the returned header information. If so, set CURLOPT_FOLLOWLOCATION

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