Home > Backend Development > PHP Tutorial > Solution to the problem when php curl post

Solution to the problem when php curl post

WBOY
Release: 2016-07-25 08:54:38
Original
941 people have browsed it
  1. $data = array( 'Title' => $title, 'Content' => $content, 'ComeFrom' => $comefrom );
  2. curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE , false);
  3. curl_setopt($ch, CURLOPT_URL, 'http://example.com/b.php');
  4. curl_setopt($ch, CURLOPT_POST, 1);
  5. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  6. curl_exec($ch);
Copy code

Send the data to be submitted in the form of an array through POST, and this will cause CURL to use the "wrong" encoding "multipart/form-data", which The effect is equivalent to directly completing the operation with a form like "

". You can try it. At this time, "b.php" cannot receive data through $_POST anyway.

So, the correct approach should be to change $data in the above code from an array to one encoded by urlencode().



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