| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | <?phpnamespace app\admin\controller;use GuzzleHttp\Client;use think\Controller;use think\Db;class Dahua extends Base{    public function index(){        $content = file_get_contents('http://127.0.0.1:4481/demo.php');        $this->assign('content',$content);        return $this->fetch();    }    public function token(){        $client_id = "re4e28ee63ef094215b80fb92eb938bdb9";        $client_secret = "9c6570bc78215b6c84e0a0639d50c91a";//        $client_id = "re4e28ee63ef094215b80fb92eb938bdb9";//        $client_secret = "9c6570bc78215b6c84e0a0639d50c91a";        $url = "https://www.cloud-dahua.com/gateway/auth/oauth/token?grant_type=client_credentials&scope=server&client_id={$client_id}&client_secret={$client_secret}";        $ret = curl_post($url,[]);        $ret = json_decode($ret,true);        return json($ret);    }    public function device(){        $authorization = request()->header()['authorization'];//        $authorization = "Bearer 2d99f770-81f3-4921-be31-2d766db87323";        $url = "https://www.cloud-dahua.com/gateway/device/api/page";        $data = [            'pageNum' => 1,            'pageSize' => 200        ];        $ret = curl_post($url,json_encode($data),['Content-Type: application/json','Authorization:'.$authorization]);//        halt($ret);        $ret = json_decode($ret,true);        return json($ret);    }    public function lechange(){        $authorization = request()->header()['authorization'];        $url = "https://www.cloud-dahua.com/gateway/device/api/lechangeToken";        $ret = curl_post($url,[],['Content-Type: application/json','Authorization:'.$authorization]);        $ret = json_decode($ret,true);        return json($ret);    }}
 |