首页 > 编程学习 > php 网页发送post请求

php 网页发送post请求

发布时间:2022/11/24 23:24:39
 function request_post($url = '', $param = '') {if (empty($url) || empty($param)) {return false;}$postUrl = $url;$curlPost = $param;$ch = curl_init();//初始化curlcurl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页curl_setopt($ch, CURLOPT_HEADER, 0);//设置headercurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上curl_setopt($ch, CURLOPT_POST, 1);//post提交方式curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);$data = curl_exec($ch);//运行curlcurl_close($ch);return $data;}



$url = 'http://120.24.59.46:9800/userApi/process_inquiry.html';//  $post_data['auth']       = '147';$post_data['order_name']      = 'order my name';$post_data['order_age'] = '99';$post_data['disease_des'] = '99_nassssssssssssme';$post_data['order_gender'] = '男';$post_data['disease_name'] = 'disease name';$post_data['disease_photos']    = '/upload/img.jpg,/upload/img.jpg';$o = "";foreach ( $post_data as $k => $v ) { $o.= "$k=" . urlencode( $v ). "&" ;}$post_data = substr($o,0,-1);//        $res = aa();$res = request_post($url, $post_data);
echo $res;



本文链接:https://www.ngui.cc/el/2111915.html
Copyright © 2010-2022 ngui.cc 版权所有 |关于我们| 联系方式| 豫B2-20100000