编程语言
首页 > 编程语言> > PHP自动提交表单的方法(基于curl)

PHP自动提交表单的方法(基于curl)

作者:互联网

 1 <?php
 2   $url = 'http://localhost/curl/result.php';//提交目的地址
 3   $params = "param=123&param2=333"; //要传送的数据
 4   $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";
 5   $ch = curl_init();
 6   curl_setopt($ch, CURLOPT_POST,1);
 7   curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
 8   curl_setopt($ch, CURLOPT_URL,$url);
 9   curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
10   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
11   $result=curl_exec ($ch); //execut
12   curl_close ($ch);
13   echo $result;//打印反馈回来的结果

//参考网址:https://www.jb51.net/article/83799.htm
14 ?>

 

标签:www,jb51,htm,表单,https,article,curl,PHP,83799
来源: https://www.cnblogs.com/pensive/p/14318409.html