今天修复了手机版的一个在线服务的表单提交问题,其中就用到这个。 实现方法蛮简单的,需要CURL支持 下面开始代码
$post_data = array(); //需要提交的post数据 $post_data['clientname'] = "test08"; $post_data['clientpasswd'] = "test08"; $post_data['submit'] = "submit"; //目标地址 $url='http://xxx.xxx.xxx.xx/xx/xxx/top.php'; $o=""; foreach ($post_data as $k=>$v) { $o.= "$k=".urlencode($v)."&"; } $post_data=substr($o,0,-1); //开始通讯 $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL,$url); //为了支持cookie curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); //返回结果 $result = curl_exec($ch);查看更多关于PHP实现模拟POST提交并返回结果的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did7827