{"id":22206416,"url":"https://github.com/xavier-lam/ys7","last_synced_at":"2025-07-27T07:32:19.504Z","repository":{"id":47451038,"uuid":"291289423","full_name":"Xavier-Lam/ys7","owner":"Xavier-Lam","description":"海康威视设备萤石开放平台(萤石云)PHP SDK,用于接入海康设备直播,通信等功能","archived":false,"fork":false,"pushed_at":"2023-04-16T06:21:09.000Z","size":45,"stargazers_count":14,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T19:11:36.210Z","etag":null,"topics":["ezuikit","ezviz","hikvision","php-sdk","ysopen"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xavier-Lam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-29T14:42:41.000Z","updated_at":"2024-09-11T13:28:44.000Z","dependencies_parsed_at":"2022-08-23T15:00:22.586Z","dependency_job_id":null,"html_url":"https://github.com/Xavier-Lam/ys7","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xavier-Lam%2Fys7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xavier-Lam%2Fys7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xavier-Lam%2Fys7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xavier-Lam%2Fys7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xavier-Lam","download_url":"https://codeload.github.com/Xavier-Lam/ys7/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227777724,"owners_count":17818455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ezuikit","ezviz","hikvision","php-sdk","ysopen"],"created_at":"2024-12-02T18:11:45.524Z","updated_at":"2024-12-02T18:11:46.243Z","avatar_url":"https://github.com/Xavier-Lam.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 萤石开放平台PHP SDK\n\n[![Packagist Version](https://img.shields.io/packagist/v/neteast/ys7)](https://packagist.org/packages/neteast/ys7)\n[![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/1BdJG31zinrMFWxRt2utGBU2jdpv8xSgju)](https://en.cryptobadges.io/donate/1BdJG31zinrMFWxRt2utGBU2jdpv8xSgju)\n\n海康威视设备萤石开放平台(萤石云)PHP SDK,用于接入海康设备直播,通信等功能\n\n官方文档:\n\u003e https://open.ys7.com/doc/zh/book/index/user.html\n\n## Installation\n    composer require neteast/ys7\n\n## Quickstart\n\n    use Neteast\\YS7\\YS7Auth;\n    use Neteast\\YS7\\YS7Client;\n\n    $auth = new YS7Auth($appKey, $appSecret);\n    $client = new YS7Client($auth);\n\n    // 新增设备\n    $client-\u003edevice-\u003eadd($deviceSerial, $validateCode);\n\n    // 获取设备列表\n    $devices = $client-\u003edevice-\u003elist();\n\n    // 获取设备信息\n    $info = $client-\u003edevice-\u003einfo($deviceSerial);\n\n    // 获取摄像头列表\n    $cameras = $client-\u003edevice-\u003ecamera-\u003elist();\n\n    // 根据设备获取摄像头列表\n    $cameras = $client-\u003edevice-\u003ecameras($deviceSerial);\n\n    // 关闭加密功能\n    $client-\u003edevice-\u003econfiguration-\u003esetEncrypt($deviceSerial, $validateCode, false);\n\n    // 开启下线通知\n    $client-\u003edevice-\u003econfiguration-\u003esetNotify($deviceSerial, true);\n\n### 云台\n    // 控制云台转动\n    $client-\u003eptz-\u003estart($deviceSerial, \\Neteast\\YS7\\Enum\\PTZ::DIRECTION_UP);\n    sleep(1);\n    $client-\u003eptz-\u003estop();\n\n### 地址获取\n    // 开通直播功能\n    $client-\u003elive-\u003eopen($deviceSerial, $channelNo);\n\n    // 获取直播地址\n    $data = $client-\u003elive-\u003eaddress($deviceSerial, $expiresIn, $channelNo);\n\n    // 获取录像列表\n    $records = $client-\u003edevice-\u003erecords($deviceSerial);\n\n    // 获取ezopen直播地址\n    $addr = $client-\u003eezopen-\u003elive($deviceSerial, $channelNo);\n    // 获取ezopen录像地址\n    $addr = $client-\u003eezopen-\u003erec($deviceSerial, $channelNo, 1598940000);\n\n### 通知\n    // 通知\n    $consumer = $client-\u003econsumer();\n    $consumer-\u003eaddHandler(function(\\Neteast\\YS7\\Message\\DataObject\\Message $message, \\Neteast\\YS7\\Message\\Consumer $consumer, YS7Client $client) {\n        // 你的处理业务逻辑\n    });\n\n    // 开始消费消息\n    while(true) {\n        $consumer-\u003econsume();\n        sleep(30);\n    }\n\n### 子账号\n    // 创建子账号\n    $accountId = $client-\u003eram-\u003eaccount-\u003ecreate($accountName, $password);\n\n    // 获取子账号信息\n    $data = $client-\u003eram-\u003eaccount-\u003eget($accountId);\n\n    // 设置子账号权限策略\n    use Neteast\\YS7\\Policy\\Permission;\n    use Neteast\\YS7\\Policy\\Resource;\n    use Neteast\\YS7\\Policy\\Statement;\n\n    $devices = [Resource::create($deviceSerial, $channelNo)];\n    $permissions = [Permission::UPDATE];\n    $statements = [Statement::create($permissions, $devices)];\n    $client-\u003eram-\u003epolicy-\u003eset($statements);\n\n    // 获取子账号auth\n    $auth = $client-\u003eram-\u003etoken-\u003eget($accountId);\n\n    // 使用子账号\n    $client = new YS7Client($auth);\n    $client-\u003edevice-\u003elist();\n\n## TODOS\n* 消息处理相关信号\n\n## Contribute\n对于需要使用并未封装的api,可依照本类库封装风格进行封装,通过pull request合作开发\n\n## Changelog\n### 0.2.0\n* 拆分httpclient\n\n### 0.1.0\n* 基本功能封装\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavier-lam%2Fys7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxavier-lam%2Fys7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavier-lam%2Fys7/lists"}