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 ?>

 

上一篇:python 新闻推荐系统毕业设计


下一篇:php 进行图片裁剪