Git Product home page Git Product logo

ys7's Introduction

萤石开放平台PHP SDK

Packagist Version Donate with Bitcoin

海康威视设备萤石开放平台(萤石云)PHP SDK,用于接入海康设备直播,通信等功能

官方文档:

https://open.ys7.com/doc/zh/book/index/user.html

Installation

composer require neteast/ys7

Quickstart

use Neteast\YS7\YS7Auth;
use Neteast\YS7\YS7Client;

$auth = new YS7Auth($appKey, $appSecret);
$client = new YS7Client($auth);

// 新增设备
$client->device->add($deviceSerial, $validateCode);

// 获取设备列表
$devices = $client->device->list();

// 获取设备信息
$info = $client->device->info($deviceSerial);

// 获取摄像头列表
$cameras = $client->device->camera->list();

// 根据设备获取摄像头列表
$cameras = $client->device->cameras($deviceSerial);

// 关闭加密功能
$client->device->configuration->setEncrypt($deviceSerial, $validateCode, false);

// 开启下线通知
$client->device->configuration->setNotify($deviceSerial, true);

云台

// 控制云台转动
$client->ptz->start($deviceSerial, \Neteast\YS7\Enum\PTZ::DIRECTION_UP);
sleep(1);
$client->ptz->stop();

地址获取

// 开通直播功能
$client->live->open($deviceSerial, $channelNo);

// 获取直播地址
$data = $client->live->address($deviceSerial, $expiresIn, $channelNo);

// 获取录像列表
$records = $client->device->records($deviceSerial);

// 获取ezopen直播地址
$addr = $client->ezopen->live($deviceSerial, $channelNo);
// 获取ezopen录像地址
$addr = $client->ezopen->rec($deviceSerial, $channelNo, 1598940000);

通知

// 通知
$consumer = $client->consumer();
$consumer->addHandler(function(\Neteast\YS7\Message\DataObject\Message $message, \Neteast\YS7\Message\Consumer $consumer, YS7Client $client) {
    // 你的处理业务逻辑
});

// 开始消费消息
while(true) {
    $consumer->consume();
    sleep(30);
}

子账号

// 创建子账号
$accountId = $client->ram->account->create($accountName, $password);

// 获取子账号信息
$data = $client->ram->account->get($accountId);

// 设置子账号权限策略
use Neteast\YS7\Policy\Permission;
use Neteast\YS7\Policy\Resource;
use Neteast\YS7\Policy\Statement;

$devices = [Resource::create($deviceSerial, $channelNo)];
$permissions = [Permission::UPDATE];
$statements = [Statement::create($permissions, $devices)];
$client->ram->policy->set($statements);

// 获取子账号auth
$auth = $client->ram->token->get($accountId);

// 使用子账号
$client = new YS7Client($auth);
$client->device->list();

TODOS

  • 消息处理相关信号

Contribute

对于需要使用并未封装的api,可依照本类库封装风格进行封装,通过pull request合作开发

Changelog

0.2.0

  • 拆分httpclient

0.1.0

  • 基本功能封装

ys7's People

Contributors

manhere avatar puzzle9 avatar xavier-lam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ys7's Issues

初始化报错

我的环境是phpstudy8.1.1.2
php版本是7.3.4nts
框架是 thinkphp3.2

头部也已经引入了
use Neteast\YS7\YS7Auth;
use Neteast\YS7\YS7Client;

    Vendor('autoload');

    $appKey = "";
    $appSecret = "";
    $auth = new YS7Auth($appKey, $appSecret);
    $client = new YS7Client($auth);

Declaration of Neteast\YS7\Auth\BaseAuth::isInvalidAuthError(Shisa\HTTPClient\Exceptions\ResponseError $e) must be compatible with Shisa\HTTPClient\Auth\AbstractAuth::isInvalidAuthError($e)

请问大佬这是什么原因呢?能给点解决这个问题思路吗?

还有我看github上面的tag版本有0.2.1 但是packagist.org上最高到 0.2.0

您好!

有没有示例源码呢?方便开发

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.