Controller|Controller CURL调用接口

$curlPost = array( 'unid'=> isset($data['unid'])?$data['unid']:'', 'term_suiji'=> isset($data['suiji'])?$data['suiji']:'', 'wxorder_id'=> 'SYKX'.date('YmdHis').rand(10000,99999), 'pay_money' => '0', 'pay_date'=> date('Y-m-d H:i:s'), ); $ch = curl_init(); //初始化 curl curl_setopt($ch, CURLOPT_URL,$GLOBALS['yurl'].'?service=App.Term.BuyTerm'); curl_setopt($ch, CURLOPT_POST, 1); //post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = https://www.it610.com/article/curl_exec($ch); //运行curl curl_close($ch); $data = json_decode($data,true); // echo' '; if($data['ret'] == 200){ $this->Session->setFlash("分配成功"); }else{ $this->Session->setFlash("分配失败:".$data['msg']); } echo " var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); parent.location.href='https://www.it610.com/Buy/Index'; "; // window.parent.location.reload(); //刷新父页面 exit();

    推荐阅读