PHP code example of imactool / dahua-cloud
1. Go to this page and download the library: Download imactool/dahua-cloud library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imactool / dahua-cloud example snippets
use Imactool\DahuaCloud\Cloud;
$config = [
'client_id' => '平台的client_id',
'client_secret' => '平台的client_secret'
];
$cloud = new Cloud($config);
//获取场所管理 的场所列表
$params = [
'pageSize' => 10,
'pageNum' => 1
];
$res = $cloud->Org->getPlaceList($params);
var_dump($res);
//获取业主二维码
$personFileId = '550970137048096768';
$res = $dh->Asc->getQrcode($personFileId);
var_dump($res);
//社区-混合云三方接口
$communityCode = '60bd440488654354bc78f46d657ab91b';
$mixSer = $dh->Mix->mixHeader($communityCode);
$params = [
'pageNum' => 1,
'pageSize' => 20
];
//查询开门记录
$res = $mixSer->doorOpenRecord($params);
var_dump($res);
//云存储 -> 查询通道是否开通云存储
$params = ['0','1','2']; //设备序列号$通道id 列表
$res = $dh->Mixed->getStorageStrategy($params);
var_dump($res);
//同步人员授权
$params =[
'channelId' => 0,
'deviceId' => '11dsdsse23432',
'operateType'=>1,
'personFileId' => '7634076932312329168'
];
$res = $dh->Asc->syncAuthPersonToDevice($params);
var_dump($res);
//远程开门
$params =[
'accessSource' => 0,
'type' => 'remote',
'deviceId' => '11dsdsse23432',
];
$res = $dh->Asc->remoteOpenDoor($params);
var_dump($res);
//查询单个设备详情
$params = [
'deviceId' =>'11dsdsse23432'
];
$res = $dh->Device->getDeviceInfo($params);
var_dump($res);
//获取开门计划
$res = $dh->Asc->getDoorTimePlan();
var_dump($res);
//添加设备
$params = [
'storeId' => '2323232323232', //要添加的组织场所id
'name' => '监控摄像测试',
'deviceId' => '11dsdsse23432',
'devUsername'=>'admin', //设备用户名(使用Base64编码传入,默认为admin) --> 不需要额外处理
'devPassword' =>'lc888888' //设备密码(使用Base64编码传入,默认为admin123)--> 不需要额外处理
];
$res = $dh->Device->addDevice($params);
var_dump($res);
//删除设备
$deviceId = '11dsdsse23432';
$res = $dh->Device->deleteDevice($deviceId);
var_dump($res);
use Imactool\DahuaCloud\Imou;
$config =[
'appId' => '', // 乐橙 appId,控制台-我的应用-应用信息中获取
'appSecret' => '', // 乐橙 appSecret
];
$imou = new Imou($config);
$params = [
'deviceId' => '11111'
];
$res = $imou->LcDevice->unBindDeviceInfo($params);
var_dump($res);
//绑定
$params = [
'deviceId' => '11111',
'code' => ''
];
$res = $imou->LcDevice->bindDevice($params);
var_dump($res);