Thinkphp中controller控制器根据curl函数请求数据

时间:2022-12-29 14:03:52
public function member(){
        $url="http://aitequn.tjnit.com/UserAction_findAllUser";
        $ch =curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $result =curl_exec($ch);
        curl_close($ch);
        $data=json_decode($result,true);
//        $count=count($data);
//        echo $count;           
//        die;
        $this->assign('data',$data);

        $this->display();