Home >Backend Development >PHP Tutorial >Simple example of php curl post

Simple example of php curl post

WBOY
WBOYOriginal
2016-07-25 08:58:441115browse
  1. //curl post example

  2. $url = 'http://bbs.it-home.org';
  3. $param1 = "param1";//Parameter 1
  4. $param2 = "param2";//Parameter 2
  5. $param3 = "param3";//Parameter 3

  6. $params = 'param1=' . $param1;

  7. $params = 'param2 =' . $param2;
  8. $params = 'param3=' . $param3;

  9. $ch = curl_init( $url );

  10. curl_setopt( $ch, CURLOPT_POST, 1);
  11. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params);
  12. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
  13. curl_setopt( $ch, CURLOPT_HEADER, 0);
  14. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

  15. < ;p>$response = curl_exec( $ch );
  16. echo 'response = '.$response."";
  17. ?>

Copy code

The above code is relatively simple and is mainly used Let’s get familiar with curl’s post usage, for reference only for beginners. Programmer's Home, I wish you all the best in your studies and progress.



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