From aa1d5ced1636e9ea3c55bb0193adda9cc448801b Mon Sep 17 00:00:00 2001 From: Cxphp Date: Thu, 10 May 2018 09:33:34 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]ComposerUpdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/database.php | 6 +- vendor/autoload.php | 2 +- vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_real.php | 14 +- vendor/composer/autoload_static.php | 9 +- vendor/composer/installed.json | 12 +- vendor/qiniu/php-sdk/CHANGELOG.md | 4 + vendor/qiniu/php-sdk/docs/rtc/README.md | 71 ++++++ vendor/qiniu/php-sdk/docs/rtc/example.php | 42 ++++ .../php-sdk/examples/rs_change_status.php | 20 ++ vendor/qiniu/php-sdk/src/Qiniu/Config.php | 4 +- .../qiniu/php-sdk/src/Qiniu/Http/Client.php | 13 +- .../qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php | 204 ++++++++++++++++++ .../src/Qiniu/Storage/BucketManager.php | 17 ++ 14 files changed, 396 insertions(+), 23 deletions(-) create mode 100644 vendor/qiniu/php-sdk/docs/rtc/README.md create mode 100644 vendor/qiniu/php-sdk/docs/rtc/example.php create mode 100644 vendor/qiniu/php-sdk/examples/rs_change_status.php create mode 100644 vendor/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php diff --git a/config/database.php b/config/database.php index f0882cd21..d0f63d7ea 100644 --- a/config/database.php +++ b/config/database.php @@ -16,13 +16,13 @@ return [ // 数据库类型 'type' => 'mysql', // 服务器地址 - 'hostname' => '127.0.0.1', + 'hostname' => 'server.cuci.cc', // 数据库名 'database' => 'admin_v3', // 用户名 - 'username' => 'admin_v3', + 'username' => 'root', // 密码 - 'password' => 'FbYBHcWKr2', + 'password' => 'Test12345', // 端口 'hostport' => '3306', // 连接dsn diff --git a/vendor/autoload.php b/vendor/autoload.php index 11af676cc..eab18267b 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9::getLoader(); +return ComposerAutoloaderInit1fdfee53212f11ec783007c682345a6b::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 76df8b0d8..d419b08cd 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -96,6 +96,7 @@ return array( 'Qiniu\\Processing\\ImageUrlBuilder' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Processing/ImageUrlBuilder.php', 'Qiniu\\Processing\\Operation' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Processing/Operation.php', 'Qiniu\\Processing\\PersistentFop' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Processing/PersistentFop.php', + 'Qiniu\\Rtc\\AppClient' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php', 'Qiniu\\Storage\\BucketManager' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php', 'Qiniu\\Storage\\FormUploader' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Storage/FormUploader.php', 'Qiniu\\Storage\\ResumeUploader' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Storage/ResumeUploader.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index e9e991e87..409c2db37 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9 +class ComposerAutoloaderInit1fdfee53212f11ec783007c682345a6b { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit1fdfee53212f11ec783007c682345a6b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit1fdfee53212f11ec783007c682345a6b', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit1fdfee53212f11ec783007c682345a6b::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInit7ecf5ded1a6830a1c375fe7293886da9 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit1fdfee53212f11ec783007c682345a6b::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire7ecf5ded1a6830a1c375fe7293886da9($fileIdentifier, $file); + composerRequire1fdfee53212f11ec783007c682345a6b($fileIdentifier, $file); } return $loader; } } -function composerRequire7ecf5ded1a6830a1c375fe7293886da9($fileIdentifier, $file) +function composerRequire1fdfee53212f11ec783007c682345a6b($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 131da8600..794ee5bcb 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9 +class ComposerStaticInit1fdfee53212f11ec783007c682345a6b { public static $files = array ( '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', @@ -179,6 +179,7 @@ class ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9 'Qiniu\\Processing\\ImageUrlBuilder' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Processing/ImageUrlBuilder.php', 'Qiniu\\Processing\\Operation' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Processing/Operation.php', 'Qiniu\\Processing\\PersistentFop' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Processing/PersistentFop.php', + 'Qiniu\\Rtc\\AppClient' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php', 'Qiniu\\Storage\\BucketManager' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php', 'Qiniu\\Storage\\FormUploader' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Storage/FormUploader.php', 'Qiniu\\Storage\\ResumeUploader' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Storage/ResumeUploader.php', @@ -275,9 +276,9 @@ class ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit7ecf5ded1a6830a1c375fe7293886da9::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit1fdfee53212f11ec783007c682345a6b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit1fdfee53212f11ec783007c682345a6b::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit1fdfee53212f11ec783007c682345a6b::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e601ce3ca..a45fca40a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -431,17 +431,17 @@ }, { "name": "qiniu/php-sdk", - "version": "v7.2.3", - "version_normalized": "7.2.3.0", + "version": "v7.2.4", + "version_normalized": "7.2.4.0", "source": { "type": "git", "url": "https://github.com/qiniu/php-sdk.git", - "reference": "67852ba9cdd7f48e0e080961abebafee134fb329" + "reference": "e5605b20aa4cab7d7ad38c2a510e7086d0d85534" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/qiniu/php-sdk/67852ba9cdd7f48e0e080961abebafee134fb329.zip", - "reference": "67852ba9cdd7f48e0e080961abebafee134fb329", + "url": "https://files.phpcomposer.com/files/qiniu/php-sdk/e5605b20aa4cab7d7ad38c2a510e7086d0d85534.zip", + "reference": "e5605b20aa4cab7d7ad38c2a510e7086d0d85534", "shasum": "" }, "require": { @@ -451,7 +451,7 @@ "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "~2.3" }, - "time": "2018-02-20T13:59:54+00:00", + "time": "2018-05-09T08:33:46+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/qiniu/php-sdk/CHANGELOG.md b/vendor/qiniu/php-sdk/CHANGELOG.md index 8547bd882..4545fdfa0 100644 --- a/vendor/qiniu/php-sdk/CHANGELOG.md +++ b/vendor/qiniu/php-sdk/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 7.2.4 (2018-05-09) +### 增加 +* 连麦功能 + ## 7.2.3 (2018-01-20) ### 增加 * 新加坡机房 diff --git a/vendor/qiniu/php-sdk/docs/rtc/README.md b/vendor/qiniu/php-sdk/docs/rtc/README.md new file mode 100644 index 000000000..7b98ca0f9 --- /dev/null +++ b/vendor/qiniu/php-sdk/docs/rtc/README.md @@ -0,0 +1,71 @@ +# Rtc Streaming Cloud Server-Side Library For PHP + +## Features + +- Appclient + - [x] 创建房间: client->createApp() + - [x] 查看房间: client->getApp() + - [x] 删除房间: client->deleteApp() + - [x] 生成房间token: client->appToken() + + + +## Contents + +- [Installation](#installation) +- [Usage](#usage) + - [Configuration](#configuration) + - [App](#app) + - [Create a app](#create-a-app) + - [Get a app](#get-a-app) + - [Delete a app](#delete-a-app) + - [Generate a app token](#generate-a-app-token) + + +## Usage + +### App + +#### Create a app + +```php +$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5"; +$sk = "xxxx"; +$auth = new Auth($ak, $sk); +$client = new Qiniu\Rtc\AppClient($auth); +$resp=$client->createApp("901","testApp"); +print_r($resp); +``` + +#### Get an app + +```php +$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5"; +$sk = "xxxx"; +$auth = new Auth($ak, $sk); +$client = new Qiniu\Rtc\AppClient($auth); +$resp=$client->getApp("deq02uhb6"); +print_r($resp); +``` + +#### Delete an app + +```php +$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5"; +$sk = "xxxx"; +$auth = new Auth($ak, $sk); +$client = new Qiniu\Rtc\AppClient($auth); +$resp=$client->deleteApp("deq02uhb6"); +print_r($resp); +``` + +#### Generate an app token + +```php +$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5"; +$sk = "xxxx"; +$auth = new Auth($ak, $sk); +$client = new Qiniu\Rtc\AppClient($auth); +$resp=$client->appToken("deq02uhb6", "lfx", '1111', (time()+3600), 'user'); +print_r($resp); +``` \ No newline at end of file diff --git a/vendor/qiniu/php-sdk/docs/rtc/example.php b/vendor/qiniu/php-sdk/docs/rtc/example.php new file mode 100644 index 000000000..f30b9b415 --- /dev/null +++ b/vendor/qiniu/php-sdk/docs/rtc/example.php @@ -0,0 +1,42 @@ +createApp($hub, $title, $maxUsers); + print_r($resp); + // 获取app状态 + $resp = $client->getApp('dgdl5ge8y'); + print_r($resp); + //修改app状态 + $mergePublishRtmp = null; + $mergePublishRtmp['enable'] = true; + $resp = $client->updateApp('dgdl5ge8y', $hub, $title, $maxUsers, $mergePublishRtmp); + print_r($resp); + //删除app + $resp = $client->deleteApp('dgdl5ge8y'); + print_r($resp); + //获取房间连麦的成员 + $resp=$client->listUser("dgbfvvzid", 'lfxl'); + print_r($resp); + //剔除房间的连麦成员 + $resp=$client->kickUser("dgbfvvzid", 'lfx', "qiniu-f6e07b78-4dc8-45fb-a701-a9e158abb8e6"); + print_r($resp); + // 列举房间 + $resp=$client->listActiveRooms("dgbfvvzid", 'lfx', null, null); + print_r($resp); + //鉴权的有效时间: 1个小时. + $resp = $client->appToken("dgd4vecde", "lfxl", '1111', (time()+3600), 'user'); + print_r($resp); +} catch (\Exception $e) { + echo "Error:", $e, "\n"; +} diff --git a/vendor/qiniu/php-sdk/examples/rs_change_status.php b/vendor/qiniu/php-sdk/examples/rs_change_status.php new file mode 100644 index 000000000..cbcea5c28 --- /dev/null +++ b/vendor/qiniu/php-sdk/examples/rs_change_status.php @@ -0,0 +1,20 @@ +changeStatus($bucket, $key, $status); +if ($err) { + print_r($err); +} diff --git a/vendor/qiniu/php-sdk/src/Qiniu/Config.php b/vendor/qiniu/php-sdk/src/Qiniu/Config.php index 296caa9cd..1af166bb6 100644 --- a/vendor/qiniu/php-sdk/src/Qiniu/Config.php +++ b/vendor/qiniu/php-sdk/src/Qiniu/Config.php @@ -3,7 +3,7 @@ namespace Qiniu; final class Config { - const SDK_VER = '7.2.3'; + const SDK_VER = '7.2.4'; const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改 @@ -11,6 +11,8 @@ final class Config const API_HOST = 'api.qiniu.com'; const RS_HOST = 'rs.qiniu.com'; //RS Host const UC_HOST = 'https://api.qiniu.com'; //UC Host + const RTCAPI_HOST = 'http://rtc.qiniuapi.com'; + const RTCAPI_VERSION = 'v3'; // Zone 空间对应的机房 public $zone; diff --git a/vendor/qiniu/php-sdk/src/Qiniu/Http/Client.php b/vendor/qiniu/php-sdk/src/Qiniu/Http/Client.php index 21beb05f8..425c314cf 100644 --- a/vendor/qiniu/php-sdk/src/Qiniu/Http/Client.php +++ b/vendor/qiniu/php-sdk/src/Qiniu/Http/Client.php @@ -13,6 +13,12 @@ final class Client return self::sendRequest($request); } + public static function delete($url, array $headers = array()) + { + $request = new Request('DELETE', $url, $headers); + return self::sendRequest($request); + } + public static function post($url, $body, array $headers = array()) { $request = new Request('POST', $url, $headers, $body); @@ -129,7 +135,7 @@ final class Client $headerLine = trim($line); $kv = explode(':', $headerLine); if (count($kv) > 1) { - $kv[0] = ucwords($kv[0], '-'); + $kv[0] =self::ucwordsHyphen($kv[0]); $headers[$kv[0]] = trim($kv[1]); } } @@ -142,4 +148,9 @@ final class Client $replace = array("\\\\", "\\\""); return str_replace($find, $replace, $str); } + + private static function ucwordsHyphen($str) + { + return str_replace('- ', '-', ucwords(str_replace('-', '- ', $str))); + } } diff --git a/vendor/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php b/vendor/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php new file mode 100644 index 000000000..c07ee72f3 --- /dev/null +++ b/vendor/qiniu/php-sdk/src/Qiniu/Rtc/AppClient.php @@ -0,0 +1,204 @@ +auth = $auth; + + $this->baseURL = sprintf("%s/%s/apps", Config::RTCAPI_HOST, Config::RTCAPI_VERSION); + } + + /* + * hub: 直播空间名 + * title: app 的名称 注意,Title 不是唯一标识,重复 create 动作将生成多个 app + * maxUsers:人数限制 + * NoAutoKickUser: bool 类型,可选,禁止自动踢人(抢流)。默认为 false , + 即同一个身份的 client (app/room/user) ,新的连麦请求可以成功,旧连接被关闭。 + */ + public function createApp($hub, $title, $maxUsers = null, $noAutoKickUser = null) + { + $params['hub'] = $hub; + $params['title'] = $title; + if (!empty($maxUsers)) { + $params['maxUsers'] = $maxUsers; + } + if (!empty($noAutoKickUser)) { + $params['noAutoKickUser'] = $noAutoKickUser; + } + $body = json_encode($params); + $ret = $this->post($this->baseURL, $body); + return $ret; + } + + /* + * appId: app 的唯一标识,创建的时候由系统生成。 + * Title: app 的名称, 可选。 + * Hub: 绑定的直播 hub,可选,用于合流后 rtmp 推流。 + * MaxUsers: int 类型,可选,连麦房间支持的最大在线人数。 + * NoAutoKickUser: bool 类型,可选,禁止自动踢人。 + * MergePublishRtmp: 连麦合流转推 RTMP 的配置,可选择。其详细配置包括如下 + Enable: 布尔类型,用于开启和关闭所有房间的合流功能。 + AudioOnly: 布尔类型,可选,指定是否只合成音频。 + Height, Width: int64,可选,指定合流输出的高和宽,默认为 640 x 480。 + OutputFps: int64,可选,指定合流输出的帧率,默认为 25 fps 。 + OutputKbps: int64,可选,指定合流输出的码率,默认为 1000 。 + URL: 合流后转推旁路直播的地址,可选,支持魔法变量配置按照连麦房间号生成不同的推流地址。如果是转推到七牛直播云,不建议使用该配置。 + StreamTitle: 转推七牛直播云的流名,可选,支持魔法变量配置按照连麦房间号生成不同的流名。例如,配置 Hub 为 qn-zhibo ,配置 StreamTitle 为 $(roomName) ,则房间 meeting-001 的合流将会被转推到 rtmp://pili-publish.qn-zhibo.***.com/qn-zhibo/meeting-001地址。详细配置细则,请咨询七牛技术支持。 + */ + public function updateApp($appId, $hub, $title, $maxUsers = null, $mergePublishRtmp = null, $noAutoKickUser = null) + { + $url = $this->baseURL . '/' . $appId; + $params['hub'] = $hub; + $params['title'] = $title; + if (!empty($maxUsers)) { + $params['maxUsers'] = $maxUsers; + } + if (!empty($noAutoKickUser)) { + $params['noAutoKickUser'] = $noAutoKickUser; + } + if (!empty($mergePublishRtmp)) { + $params['mergePublishRtmp'] = $mergePublishRtmp; + } + $body = json_encode($params); + $ret = $this->post($url, $body); + return $ret; + } + + /* + * appId: app 的唯一标识,创建的时候由系统生成。 + */ + public function getApp($appId) + { + $url = $this->baseURL . '/' . $appId; + $ret = $this->get($url); + return $ret; + } + + /* + * appId: app 的唯一标识,创建的时候由系统生成 + */ + public function deleteApp($appId) + { + $url = $this->baseURL . '/' . $appId; + list(, $err) = $this->delete($url); + return $err; + } + + /* + * 获取房间的人数 + * appId: app 的唯一标识,创建的时候由系统生成。 + * roomName: 操作所查询的连麦房间。 + */ + public function listUser($appId, $roomName) + { + $url = sprintf("%s/%s/rooms/%s/users", $this->baseURL, $appId, $roomName); + $ret = $this->get($url); + return $ret; + } + + /* + * 踢出玩家 + * appId: app 的唯一标识,创建的时候由系统生成。 + * roomName: 连麦房间 + * userId: 请求加入房间的用户ID + */ + public function kickUser($appId, $roomName, $userId) + { + $url = sprintf("%s/%s/rooms/%s/users/%s", $this->baseURL, $appId, $roomName, $userId); + list(, $err) = $this->delete($url); + return $err; + } + + /* + * 获取房间的人数 + * appId: app 的唯一标识,创建的时候由系统生成。 + * prefix: 所查询房间名的前缀索引,可以为空。 + * offset: int 类型,分页查询的位移标记。 + * limit: int 类型,此次查询的最大长度。 + * GET /v3/apps//rooms?prefix=&offset=&limit= + */ + public function listActiveRooms($appId, $prefix = null, $offset = null, $limit = null) + { + if (isset($prefix)) { + $query['prefix'] = $prefix; + } + if (isset($offset)) { + $query['offset'] = $offset; + } + if (isset($limit)) { + $query['limit'] = $limit; + } + if (isset($query) && !empty($query)) { + $query = '?' . http_build_query($query); + $url = sprintf("%s/%s/rooms%s", $this->baseURL, $appId, $query); + } else { + $url = sprintf("%s/%s/rooms", $this->baseURL, $appId); + } + $ret = $this->get($url); + return $ret; + } + + /* + * appId: app 的唯一标识,创建的时候由系统生成。 + * roomName: 房间名称,需满足规格 ^[a-zA-Z0-9_-]{3,64}$ + * userId: 请求加入房间的用户 ID,需满足规格 ^[a-zA-Z0-9_-]{3,50}$ + * expireAt: int64 类型,鉴权的有效时间,传入以秒为单位的64位Unix + 绝对时间,token 将在该时间后失效。 + * permission: 该用户的房间管理权限,"admin" 或 "user",默认为 "user" 。 + 当权限角色为 "admin" 时,拥有将其他用户移除出房间等特权. + */ + public function appToken($appId, $roomName, $userId, $expireAt, $permission) + { + $params['appId'] = $appId; + $params['userId'] = $userId; + $params['roomName'] = $roomName; + $params['permission'] = $permission; + $params['expireAt'] = $expireAt; + $appAccessString = json_encode($params); + return $this->auth->signWithData($appAccessString); + } + + private function get($url, $cType = null) + { + $rtcToken = $this->auth->authorizationV2($url, "GET", null, $cType); + $rtcToken['Content-Type'] = $cType; + $ret = Client::get($url, $rtcToken); + if (!$ret->ok()) { + return array(null, new Error($url, $ret)); + } + return array($ret->json(), null); + } + + private function delete($url, $contentType = 'application/json') + { + $rtcToken = $this->auth->authorizationV2($url, "DELETE", null, $contentType); + $rtcToken['Content-Type'] = $contentType; + $ret = Client::delete($url, $rtcToken); + if (!$ret->ok()) { + return array(null, new Error($url, $ret)); + } + return array($ret->json(), null); + } + + private function post($url, $body, $contentType = 'application/json') + { + $rtcToken = $this->auth->authorizationV2($url, "POST", $body, $contentType); + $rtcToken['Content-Type'] = $contentType; + $ret = Client::post($url, $body, $rtcToken); + if (!$ret->ok()) { + return array(null, new Error($url, $ret)); + } + $r = ($ret->body === null) ? array() : $ret->json(); + return array($r, null); + } +} diff --git a/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php b/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php index d5269f381..2e82a1477 100644 --- a/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php +++ b/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php @@ -225,6 +225,23 @@ final class BucketManager return $error; } + /** + * 修改文件的存储状态,即禁用状态和启用状态间的的互相转换 + * + * @param $bucket 待操作资源所在空间 + * @param $key 待操作资源文件名 + * @param $status 待操作文件目标文件类型 + * + * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error + * @link https://developer.qiniu.com/kodo/api/4173/modify-the-file-status + */ + public function changeStatus($bucket, $key, $status) + { + $resource = \Qiniu\entry($bucket, $key); + $path = '/chstatus/' . $resource . '/status/' . $status; + list(, $error) = $this->rsPost($path); + return $error; + } /** * 从指定URL抓取资源,并将该资源存储到指定空间中