资源描述:
《手把手教你php对接海康api.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、
2、;//acceptpublic$person_list_url="/artemis/api/resource/v1/encodeDevice/get";//人员列表urlpublic$equipment_view_url="/artemis/api/video/v1/cameras/previewURLs";//获取监控点预览取流URLpublicfunction__construct($app_key='',$app_secret=''){if($app_key!='')$this->app_key=$app_ke
3、y;if($app_secret!='')$this->app_secret=$app_secret;$this->charset='utf-8';list($msec,$sec)=explode('',microtime());$this->time=(float)sprintf('%.0f',(floatval($msec)+floatval($sec))*1000);}functiongetViewUrl($cameraIndexCode){//请求参数$postData['cameraIndexCode']=
4、$cameraIndexCode;$postData['streamType']=0;$postData['protocol']='hls';$postData['transmode']=1;$sign=$this->get_sign($postData,$this->equipment_view_url);$options=array(CURLOPT_HTTPHEADER=>array("Accept:".$this->accept,"Content-Type:".$this->content_type,"X-Ca
5、-Key:".$this->app_key,"X-Ca-Signature:".$sign,"Date:".$this->time,"X-Ca-Signature-Headers:"."x-ca-key",));$result=$this->curlPost($this->pre_url.$this->equipment_view_url,json_encode($postData),$options);returnjson_decode($result,true);}/***获取人员列表*/functionget_
6、person_list($response){//请求参数$postData['pageNo']=isset($response['pageNo'])?intval($response['pageNo']):"1";$postData['pageSize']=isset($response['pageSize'])?intval($response['pageSize']):"1000";$sign=$this->get_sign($postData,$this->person_list_url);$options=
7、array(CURLOPT_HTTPHEADER=>array("Accept:".$this->accept,"Content-Type:".$this->content_type,"X-Ca-Key:".$this->app_key,"X-Ca-Signature:".$sign,"Date:".$this->time,"X-Ca-Signature-Headers:"."x-ca-key",));$result=$this->curlPost($this->pre_url.$this->person_list_
8、url,json_encode($postData),$options);returnjson_decode($result,true);}/***以appSecret为密钥,使用HmacSHA256算法对签名字符串生成消息摘要,对消息摘要使用BASE64算法生成签名(签名过程中的编码方式全为UTF-8)*/functionget_sign($