您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
curl的post方式提交数据
发布时间:2017-04-19 19:14:03编辑:雪饮阅读()
public function registerCheckCode($code){
$post_data = array ("msg_id" =>$_SESSION['msg_id'],"code"=>$code);
$curlstr="http://".$_SERVER["SERVER_NAME"]."/index.php/Index/Api/checkCode/";
$ch=curl_init();//初始化
curl_setopt($ch,CURLOPT_URL,$curlstr);//设置访问网页的URL
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//执行之后不直接打印出来
curl_setopt($ch, CURLOPT_POST, 1);//允许post
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);//设置post传递
$output=curl_exec($ch);//执行
curl_close($ch);
return json_decode($output);
}
关键字词:curl,post,提交