利用curl给你接口传递参数 为什么一直是空的 代码如下:
$useraccounts = $_post['useraccounts']; $userpassword = md5($_post['userpassword']); if($useraccounts == || $userpassword == ) { echo 请将数据填写完整; }else { $url = 'http://192.168.1.135:9999/mjs/user/userregistersign'; $data = array( 'useraccounts' => $useraccounts, 'userpassword' => $userpassword ); $json_data = postdata($url, $data); } function postdata($url, $data) { $ch = curl_init(); $timeout = 300; curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); $handles = curl_exec($ch); curl_close($ch); /* return $handles;*/ }
回复内容: 利用curl给你接口传递参数 为什么一直是空的 代码如下:
$useraccounts = $_post['useraccounts']; $userpassword = md5($_post['userpassword']); if($useraccounts == || $userpassword == ) { echo 请将数据填写完整; }else { $url = 'http://192.168.1.135:9999/mjs/user/userregistersign'; $data = array( 'useraccounts' => $useraccounts, 'userpassword' => $userpassword ); $json_data = postdata($url, $data); } function postdata($url, $data) { $ch = curl_init(); $timeout = 300; curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); $handles = curl_exec($ch); curl_close($ch); /* return $handles;*/ }
http_build_query($data)