添加网站文件
This commit is contained in:
12
vendor/qiniu/php-sdk/.gitignore
vendored
Normal file
12
vendor/qiniu/php-sdk/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
*.phar
|
||||
*.zip
|
||||
build/artifacts
|
||||
phpunit.xml
|
||||
phpunit.functional.xml
|
||||
.DS_Store
|
||||
.swp
|
||||
.build
|
||||
composer.lock
|
||||
vendor
|
||||
src/package.xml
|
||||
.idea/
|
||||
42
vendor/qiniu/php-sdk/.scrutinizer.yml
vendored
Normal file
42
vendor/qiniu/php-sdk/.scrutinizer.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
filter:
|
||||
excluded_paths: [tests/*]
|
||||
checks:
|
||||
php:
|
||||
code_rating: true
|
||||
remove_extra_empty_lines: true
|
||||
remove_php_closing_tag: true
|
||||
remove_trailing_whitespace: true
|
||||
fix_use_statements:
|
||||
remove_unused: true
|
||||
preserve_multiple: false
|
||||
preserve_blanklines: true
|
||||
order_alphabetically: true
|
||||
fix_php_opening_tag: true
|
||||
fix_linefeed: true
|
||||
fix_line_ending: true
|
||||
fix_identation_4spaces: true
|
||||
fix_doc_comments: true
|
||||
tools:
|
||||
external_code_coverage:
|
||||
timeout: 1200
|
||||
runs: 3
|
||||
php_analyzer: true
|
||||
php_code_coverage: false
|
||||
php_code_sniffer:
|
||||
config:
|
||||
standard: PSR2
|
||||
filter:
|
||||
paths: ['src']
|
||||
php_loc:
|
||||
enabled: true
|
||||
excluded_dirs: [vendor, tests]
|
||||
php_cpd:
|
||||
enabled: true
|
||||
excluded_dirs: [vendor, tests]
|
||||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
tests:
|
||||
override:
|
||||
- php-scrutinizer-run
|
||||
|
||||
29
vendor/qiniu/php-sdk/.travis.yml
vendored
Normal file
29
vendor/qiniu/php-sdk/.travis.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
|
||||
dist: trusty
|
||||
os: linux
|
||||
|
||||
before_script:
|
||||
- export QINIU_TEST_ENV="travis"
|
||||
- travis_retry composer self-update
|
||||
- travis_retry composer install --no-interaction --prefer-source --dev
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpcs --standard=PSR2 src
|
||||
- ./vendor/bin/phpcs --standard=PSR2 examples
|
||||
- ./vendor/bin/phpcs --standard=PSR2 tests
|
||||
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
|
||||
env:
|
||||
global:
|
||||
- QINIU_ACCESS_KEY=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5
|
||||
- secure: "V9BsntXQZwvO9EOD6itzaae2uq+GemzyTUTxMTJx1/jFoUNpCU2O2UAgjA2XSEr5sgci0KWDV4Krbzv3EBB4uplOFLMI3w32256UHbT9E0x3YjhfPJZk68MH1iS1be7X81LDHON7yveavK8987s3qzjeUcbfLSPgccT+cvf7+dc="
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
132
vendor/qiniu/php-sdk/CHANGELOG.md
vendored
Normal file
132
vendor/qiniu/php-sdk/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
# Changelog
|
||||
|
||||
## 7.3.0 (2020-09-24)
|
||||
### 新增
|
||||
* 【对象存储】增加异步抓取方法与demo
|
||||
* 【融合cdn】增加查询CDN刷新记录、查询CDN预取记录方法与demo
|
||||
* 【云短信】增加查询短信发送记录的方法
|
||||
* 【实时音视频】增加rtc停止房间的合流转推方法
|
||||
* 【内容审核】增加图片审核、视频审核方法与demo
|
||||
|
||||
### 修复
|
||||
* 【对象存储】修复签算 token 时上传策略中的 forceSaveKey 字段不生效的问题
|
||||
* 【对象存储】修复更新空间事件通知规则方法
|
||||
|
||||
### 优化
|
||||
* 【对象存储】创建空间迁移到mkbucketv3 api
|
||||
* 优化对 http2 返回头的判断
|
||||
* 优化 demo 中的文档注释说明
|
||||
* docs 目录下的 rtc demo 移动至 examples/rtc 目录下
|
||||
* docs 目录下的 sms demo 移动至 examples/sms 目录下
|
||||
|
||||
## 7.2.10 (2019-10-28)
|
||||
* 去除云短信类类型指定
|
||||
* 修改不传文件名时存在表单上传错误的情况
|
||||
|
||||
## 7.2.9 (2019-07-09)
|
||||
* 添加空间管理、云短信接口
|
||||
* 去除无效参数
|
||||
|
||||
## 7.2.7 (2018-11-06)
|
||||
* 添加 QVM 内网上传到 KODO 的 zone 设置
|
||||
|
||||
## 7.2.6 (2018-05-18)
|
||||
* 修复rs,rsf在不同机房默认的https域名
|
||||
|
||||
## 7.2.5 (2018-05-10)
|
||||
* 修复表单上传中多余的参数checkCrc导致的fname错位问题
|
||||
|
||||
## 7.2.4 (2018-05-09)
|
||||
### 增加
|
||||
* 连麦功能
|
||||
|
||||
## 7.2.3 (2018-01-20)
|
||||
### 增加
|
||||
* 新加坡机房
|
||||
### 修正
|
||||
* 获取域名的入口域名
|
||||
* http回复头部兼容大小写
|
||||
|
||||
## 7.2.2 (2017-11-06)
|
||||
### 增加
|
||||
* Qiniu算法的鉴权方法
|
||||
|
||||
## 7.1.4 (2017-06-21)
|
||||
### 增加
|
||||
* cdn 文件/目录 刷新
|
||||
* cdn 获取 流量/带宽
|
||||
* cdn 获取域名的访问日志列表
|
||||
* cdn 对资源链接进行时间戳防盗链签名
|
||||
|
||||
## 7.1.3 (2016-11-18)
|
||||
### 增加
|
||||
* move, copy操作增加force参数
|
||||
|
||||
## 7.1.2 (2016-11-12)
|
||||
### 修正
|
||||
* 明确抛出获取各区域域名失败时的报错
|
||||
|
||||
## 7.1.1 (2016-11-02)
|
||||
### 修正
|
||||
* 多区域配置文件存储目录从home修改到tmp目录
|
||||
|
||||
|
||||
## 7.1.0 (2016-10-22)
|
||||
### 增加
|
||||
* 多存储区域的支持
|
||||
|
||||
## 7.0.8 (2016-07-19)
|
||||
### 增加
|
||||
* demo
|
||||
* https url 支持
|
||||
* deleteAfterDays 策略
|
||||
* 添加图片处理链接统一拼接方法 by @SherlockRen
|
||||
|
||||
## 7.0.7 (2016-01-12)
|
||||
### 修正
|
||||
* PersistentFop参数pipeline和notify_url失效
|
||||
* resume 模式 close file inputstream
|
||||
|
||||
## 7.0.6 (2015-12-05)
|
||||
### 修正
|
||||
* php7.0 Json 对空字符串解析单元测试报错
|
||||
* 开启安全模式或者设置可操作目录树时,设置CURLOPT_FOLLOWLOCATION报错, by @twocabbages
|
||||
* fetch 支持不指定key, by @sinkcup
|
||||
|
||||
## 7.0.5 (2015-10-29)
|
||||
### 增加
|
||||
* 增加上传策略最小文件大小限制 fsizeMin
|
||||
* 增加常见examples
|
||||
|
||||
## 7.0.4 (2015-07-23)
|
||||
### 修正
|
||||
* 一些地方的严格比较检查
|
||||
* resumeupload 备用地址失效
|
||||
|
||||
## 7.0.3 (2015-07-10)
|
||||
### 修改
|
||||
* 多zone 支持
|
||||
|
||||
## 7.0.2 (2015-04-18)
|
||||
### 修改
|
||||
* fetch 接口返回内容调整
|
||||
* pfop 接口调整
|
||||
|
||||
###修正
|
||||
* exception 类调用
|
||||
|
||||
## 7.0.1 (2015-03-27)
|
||||
### 增加
|
||||
* 增加代码注释
|
||||
|
||||
## 7.0.0 (2015-02-03)
|
||||
|
||||
### 增加
|
||||
* 简化上传接口
|
||||
* 自动选择断点续上传还是直传
|
||||
* 重构代码,接口和内部结构更清晰
|
||||
* 改变mime
|
||||
* 代码覆盖度报告
|
||||
* policy改为array, 便于灵活增加,并加入过期字段检查
|
||||
* 文件列表支持目录形式
|
||||
* 利用元编程方式支持 fop 和 pfop
|
||||
30
vendor/qiniu/php-sdk/CONTRIBUTING.md
vendored
Normal file
30
vendor/qiniu/php-sdk/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# 贡献代码指南
|
||||
|
||||
我们非常欢迎大家来贡献代码,我们会向贡献者致以最诚挚的敬意。
|
||||
|
||||
一般可以通过在Github上提交[Pull Request](https://github.com/qiniu/php-sdk)来贡献代码。
|
||||
|
||||
## Pull Request要求
|
||||
|
||||
- **[PSR-2 编码风格标准](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** 。要通过项目中的code sniffer检查。
|
||||
|
||||
- **代码格式** 提交前 请按 ./vendor/bin/phpcbf --standard=PSR2 进行格式化。
|
||||
|
||||
- **必须添加测试!** - 如果没有测试(单元测试、集成测试都可以),那么提交的补丁是不会通过的。
|
||||
|
||||
- **记得更新文档** - 保证`README.md`以及其他相关文档及时更新,和代码的变更保持一致性。
|
||||
|
||||
- **考虑我们的发布周期** - 我们的版本号会服从[SemVer v2.0.0](http://semver.org/),我们绝对不会随意变更对外的API。
|
||||
|
||||
- **创建feature分支** - 最好不要从你的master分支提交 pull request。
|
||||
|
||||
- **一个feature提交一个pull请求** - 如果你的代码变更了多个操作,那就提交多个pull请求吧。
|
||||
|
||||
- **清晰的commit历史** - 保证你的pull请求的每次commit操作都是有意义的。如果你开发中需要执行多次的即时commit操作,那么请把它们放到一起再提交pull请求。
|
||||
|
||||
## 运行测试
|
||||
|
||||
``` bash
|
||||
./vendor/bin/phpunit tests/Qiniu/Tests/
|
||||
|
||||
```
|
||||
22
vendor/qiniu/php-sdk/LICENSE
vendored
Normal file
22
vendor/qiniu/php-sdk/LICENSE
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Qiniu, Ltd.<sdk@qiniu.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
76
vendor/qiniu/php-sdk/README.md
vendored
Normal file
76
vendor/qiniu/php-sdk/README.md
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# Qiniu Cloud SDK for PHP
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.org/qiniu/php-sdk)
|
||||
[](https://github.com/qiniu/php-sdk/releases)
|
||||
[](https://packagist.org/packages/qiniu/php-sdk)
|
||||
[](https://packagist.org/packages/qiniu/php-sdk)
|
||||
[](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master)
|
||||
[](https://codecov.io/gh/qiniu/php-sdk)
|
||||
[](https://gitter.im/qiniu/php-sdk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](http://weibo.com/qiniutek)
|
||||
|
||||
|
||||
## 安装
|
||||
|
||||
* 推荐使用 `composer` 进行安装。可以使用 composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 [`qiniu/php-sdk`][install-packagist] 。
|
||||
```bash
|
||||
$ composer require qiniu/php-sdk
|
||||
```
|
||||
* 直接下载安装,SDK 没有依赖其他第三方库,但需要参照 composer 的 autoloader,增加一个自己的 autoloader 程序。
|
||||
|
||||
## 运行环境
|
||||
|
||||
| Qiniu SDK版本 | PHP 版本 |
|
||||
|:--------------------:|:---------------------------:|
|
||||
| 7.x | cURL extension, 5.3 - 5.6,7.0 |
|
||||
| 6.x | cURL extension, 5.2 - 5.6 |
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 上传
|
||||
```php
|
||||
use Qiniu\Storage\UploadManager;
|
||||
use Qiniu\Auth;
|
||||
...
|
||||
$uploadMgr = new UploadManager();
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$token = $auth->uploadToken($bucket);
|
||||
list($ret, $error) = $uploadMgr->putFile($token, 'key', 'filePath');
|
||||
...
|
||||
```
|
||||
|
||||
## 测试
|
||||
|
||||
``` bash
|
||||
$ ./vendor/bin/phpunit tests/Qiniu/Tests/
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
- `$error` 保留了请求响应的信息,失败情况下 `ret` 为 `none`, 将 `$error` 可以打印出来,提交给我们。
|
||||
- API 的使用 demo 可以参考 [examples](https://github.com/qiniu/php-sdk/tree/master/examples)。
|
||||
|
||||
## 代码贡献
|
||||
|
||||
详情参考[代码提交指南](https://github.com/qiniu/php-sdk/blob/master/CONTRIBUTING.md)。
|
||||
|
||||
## 贡献记录
|
||||
|
||||
- [所有贡献者](https://github.com/qiniu/php-sdk/contributors)
|
||||
|
||||
## 联系我们
|
||||
|
||||
- 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 support@qiniu.com 发送邮件)
|
||||
- 如果有什么问题,可以到问答社区提问,[问答社区](https://qiniu.segmentfault.com/)
|
||||
- 更详细的文档,见[官方文档站](https://developer.qiniu.com/)
|
||||
- 如果发现了 bug, 欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
|
||||
- 如果有功能需求,欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
|
||||
- 如果要提交代码,欢迎提交 pull request
|
||||
- 欢迎关注我们的[微信](https://www.qiniu.com/#weixin) [微博](https://weibo.com/qiniutek),及时获取动态信息。
|
||||
|
||||
## 代码许可
|
||||
|
||||
The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/php-sdk/blob/master/LICENSE).
|
||||
|
||||
[packagist]: http://packagist.org
|
||||
[install-packagist]: https://packagist.org/packages/qiniu/php-sdk
|
||||
14
vendor/qiniu/php-sdk/autoload.php
vendored
Normal file
14
vendor/qiniu/php-sdk/autoload.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
function classLoader($class)
|
||||
{
|
||||
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
||||
$file = __DIR__ . '/src/' . $path . '.php';
|
||||
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
spl_autoload_register('classLoader');
|
||||
|
||||
require_once __DIR__ . '/src/Qiniu/functions.php';
|
||||
26
vendor/qiniu/php-sdk/composer.json
vendored
Normal file
26
vendor/qiniu/php-sdk/composer.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "qiniu/php-sdk",
|
||||
"type": "library",
|
||||
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
|
||||
"keywords": ["qiniu", "storage", "sdk", "cloud"],
|
||||
"homepage": "http://developer.qiniu.com/",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Qiniu",
|
||||
"email": "sdk@qiniu.com",
|
||||
"homepage": "http://www.qiniu.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "~2.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {"Qiniu\\": "src/Qiniu"},
|
||||
"files": ["src/Qiniu/functions.php"]
|
||||
}
|
||||
}
|
||||
10
vendor/qiniu/php-sdk/examples/README.md
vendored
Normal file
10
vendor/qiniu/php-sdk/examples/README.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# examples
|
||||
|
||||
这些 examples 旨在帮助你快速了解使用七牛的 SDK。这些 demo 都是可以直接运行的, 但是在运行之前需要填上您自己的参数。
|
||||
|
||||
比如:
|
||||
|
||||
* `$bucket` 需要填上您想操作的 [bucket名字](https://portal.qiniu.com/kodo/bucket)。
|
||||
* `$accessKey` 和 `$secretKey` 可以在我们的[管理后台](https://portal.qiniu.com/user/key)找到。
|
||||
* 在进行`视频转码`, `压缩文件`等异步操作时 需要使用到的队列名称也可以在我们[管理后台](https://portal.qiniu.com/dora/media-gate/pipeline)新建。
|
||||
|
||||
36
vendor/qiniu/php-sdk/examples/bucket_lifecycleRule.php
vendored
Normal file
36
vendor/qiniu/php-sdk/examples/bucket_lifecycleRule.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 存储空间 - 新增生命周期规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
$name = 'demo'; // 生命周期规则名称
|
||||
$prefix = 'test'; // 规则策略中的前缀
|
||||
$delete_after_days = 80; // 用户新创建的文件将在该设定时间之后自动删除
|
||||
$to_line_after_days = 70; // 用户新创建的文件将在该设定的时间之后自动转为低频存储
|
||||
|
||||
list($ret, $err) = $bucketManager->bucketLifecycleRule(
|
||||
$bucket,
|
||||
$name,
|
||||
$prefix,
|
||||
$delete_after_days,
|
||||
$to_line_after_days
|
||||
);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
41
vendor/qiniu/php-sdk/examples/cdn_get_bandwidth.php
vendored
Normal file
41
vendor/qiniu/php-sdk/examples/cdn_get_bandwidth.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 获取流量和带宽数据
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1230/traffic-bandwidth
|
||||
|
||||
$domains = array(
|
||||
"javasdk.qiniudn.com",
|
||||
"phpsdk.qiniudn.com"
|
||||
);
|
||||
|
||||
$startDate = "2020-08-03";
|
||||
$endDate = "2020-08-05";
|
||||
|
||||
// 5min or hour or day
|
||||
$granularity = "day";
|
||||
|
||||
list($bandwidthData, $getBandwidthErr) = $cdnManager->getBandwidthData(
|
||||
$domains,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$granularity
|
||||
);
|
||||
|
||||
if ($getBandwidthErr != null) {
|
||||
var_dump($getBandwidthErr);
|
||||
} else {
|
||||
echo "get bandwidth data success\n";
|
||||
print_r($bandwidthData);
|
||||
}
|
||||
35
vendor/qiniu/php-sdk/examples/cdn_get_flux.php
vendored
Normal file
35
vendor/qiniu/php-sdk/examples/cdn_get_flux.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use \Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 获取流量和带宽数据
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1230/traffic-bandwidth
|
||||
|
||||
$domains = array(
|
||||
"javasdk.qiniudn.com",
|
||||
"phpsdk.qiniudn.com"
|
||||
);
|
||||
|
||||
$startDate = "2020-08-03";
|
||||
$endDate = "2020-08-05";
|
||||
|
||||
//5min or hour or day
|
||||
$granularity = "day";
|
||||
|
||||
list($fluxData, $getFluxErr) = $cdnManager->getFluxData($domains, $startDate, $endDate, $granularity);
|
||||
if ($getFluxErr != null) {
|
||||
var_dump($getFluxErr);
|
||||
} else {
|
||||
echo "get flux data success\n";
|
||||
print_r($fluxData);
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/cdn_get_log_list.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/cdn_get_log_list.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 获取日志下载链接
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1226/download-the-log
|
||||
|
||||
$domains = array(
|
||||
"javasdk.qiniudn.com",
|
||||
"phpsdk.qiniudn.com"
|
||||
);
|
||||
|
||||
$logDate = '2020-08-05';
|
||||
|
||||
list($logListData, $getLogErr) = $cdnManager->getCdnLogList($domains, $logDate);
|
||||
if ($getLogErr != null) {
|
||||
var_dump($getLogErr);
|
||||
} else {
|
||||
echo "get cdn log list success\n";
|
||||
print_r($logListData);
|
||||
}
|
||||
46
vendor/qiniu/php-sdk/examples/cdn_get_prefetch_list.php
vendored
Normal file
46
vendor/qiniu/php-sdk/examples/cdn_get_prefetch_list.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 查询 CDN 预取记录
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1227/file-prefetching#4
|
||||
|
||||
$requestId = null; // 指定要查询记录所在的刷新请求id
|
||||
|
||||
// 要查询的url列表
|
||||
$urls = array(
|
||||
"http://sdk.peterpy.cn/sdktest.png",
|
||||
"http://sdk.peterpy.cn/qiniulogo.png"
|
||||
);
|
||||
|
||||
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
|
||||
$pageNo = 0; // 要求返回的页号,默认为0
|
||||
$pageSize = 100; // 要求返回的页长度,默认为100
|
||||
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
|
||||
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
|
||||
|
||||
list($ret, $err) = $cdnManager->getCdnPrefetchList(
|
||||
$requestId,
|
||||
$urls,
|
||||
$state,
|
||||
$pageNo,
|
||||
$pageSize,
|
||||
$startTime,
|
||||
$endTime
|
||||
);
|
||||
echo "\n====> query prefetch list: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
48
vendor/qiniu/php-sdk/examples/cdn_get_refresh_list.php
vendored
Normal file
48
vendor/qiniu/php-sdk/examples/cdn_get_refresh_list.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 查询 CDN 刷新记录
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh#4
|
||||
|
||||
$requestId = 'xxxxxx'; // 指定要查询记录所在的刷新请求id
|
||||
$isDir = 'no'; // 指定是否查询目录,取值为yes/no,默认不填则为两种类型记录都查询
|
||||
|
||||
// 要查询的url列表,每个url可以是文件url,也可以是目录url
|
||||
$urls = array(
|
||||
"http://sdk.peterpy.cn/sdktest.png",
|
||||
"http://sdk.peterpy.cn/qiniulogo.png"
|
||||
);
|
||||
|
||||
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
|
||||
$pageNo = 0; // 要求返回的页号,默认为0
|
||||
$pageSize = 100; // 要求返回的页长度,默认为100
|
||||
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
|
||||
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
|
||||
|
||||
list($ret, $err) = $cdnManager->getCdnRefreshList(
|
||||
$requestId,
|
||||
$isDir,
|
||||
$urls,
|
||||
$state,
|
||||
$pageNo,
|
||||
$pageSize,
|
||||
$startTime,
|
||||
$endTime
|
||||
);
|
||||
echo "\n====> query refresh list: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
59
vendor/qiniu/php-sdk/examples/cdn_refresh_urls_dirs.php
vendored
Normal file
59
vendor/qiniu/php-sdk/examples/cdn_refresh_urls_dirs.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
//---------------------------------------- demo1 ----------------------------------------
|
||||
// 刷新文件和目录
|
||||
// 文件列表一次最多提交 60 个,目录一次最多提交 10 个
|
||||
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh
|
||||
|
||||
$urls = array(
|
||||
"http://phpsdk.qiniudn.com/qiniu.jpg",
|
||||
"http://phpsdk.qiniudn.com/qiniu2.jpg",
|
||||
);
|
||||
|
||||
$dirs = array(
|
||||
"http://phpsdk.qiniudn.com/test/"
|
||||
);
|
||||
|
||||
$cdnManager = new CdnManager($auth);
|
||||
|
||||
// 如果刷新返回 400038 报错,则需要联系七牛技术支持开通刷新目录权限,参考:https://developer.qiniu.com/fusion/api/1229/cache-refresh,
|
||||
list($refreshResult, $refreshErr) = $cdnManager->refreshUrlsAndDirs($urls, $dirs);
|
||||
if ($refreshErr != null) {
|
||||
var_dump($refreshErr);
|
||||
} else {
|
||||
echo "refresh request sent\n";
|
||||
print_r($refreshResult);
|
||||
}
|
||||
|
||||
//---------------------------------------- demo2 ----------------------------------------
|
||||
// 刷新文件
|
||||
|
||||
list($refreshResult, $refreshErr) = $cdnManager->refreshUrls($urls);
|
||||
if ($refreshErr != null) {
|
||||
var_dump($refreshErr);
|
||||
} else {
|
||||
echo "refresh urls request sent\n";
|
||||
print_r($refreshResult);
|
||||
}
|
||||
|
||||
//---------------------------------------- demo3 ----------------------------------------
|
||||
// 刷新目录
|
||||
|
||||
list($refreshResult, $refreshErr) = $cdnManager->refreshDirs($dirs);
|
||||
if ($refreshErr != null) {
|
||||
var_dump($refreshErr);
|
||||
} else {
|
||||
echo "refresh dirs request sent\n";
|
||||
print_r($refreshResult);
|
||||
}
|
||||
20
vendor/qiniu/php-sdk/examples/cdn_timestamp_antileech.php
vendored
Normal file
20
vendor/qiniu/php-sdk/examples/cdn_timestamp_antileech.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Cdn\CdnManager;
|
||||
|
||||
// 创建带时间戳防盗链的 URL
|
||||
// 参考文档:https://developer.qiniu.com/fusion/manual/3841/timestamp-hotlinking-prevention-fusion
|
||||
|
||||
$encryptKey = 'your_domain_timestamp_antileech_encryptkey';
|
||||
|
||||
// 一定要带访问协议,也就是 http:// 或者 https://
|
||||
$url1 = 'http://phpsdk.qiniuts.com/24.jpg?imageInfo';
|
||||
$url2 = 'http://phpsdk.qiniuts.com/24.jpg';
|
||||
|
||||
// 有效期时间(单位秒)
|
||||
$durationInSeconds = 3600;
|
||||
|
||||
$signedUrl = CdnManager::createTimestampAntiLeechUrl($url1, $encryptKey, $durationInSeconds);
|
||||
print($signedUrl);
|
||||
42
vendor/qiniu/php-sdk/examples/censor_image.php
vendored
Normal file
42
vendor/qiniu/php-sdk/examples/censor_image.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\ArgusManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$argusManager = new ArgusManager($auth, $config);
|
||||
|
||||
// 图片内容审核
|
||||
// 参考文档:https://developer.qiniu.com/censor/api/5588/image-censor
|
||||
|
||||
$body = '{
|
||||
"data":{
|
||||
"uri":"https://www-static.qbox.me/_next/static/media/pic01.c8b5db2cc5fcb6fc4e6349c9e37c8e6b.png"
|
||||
},
|
||||
"params":{
|
||||
"scenes":[
|
||||
"pulp",
|
||||
"terror",
|
||||
"politician",
|
||||
"ads"
|
||||
]
|
||||
}
|
||||
}';
|
||||
|
||||
list($ret, $err) = $argusManager->censorImage($body);
|
||||
echo "\n====> Result is: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
52
vendor/qiniu/php-sdk/examples/censor_video.php
vendored
Normal file
52
vendor/qiniu/php-sdk/examples/censor_video.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\ArgusManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$argusManager = new ArgusManager($auth, $config);
|
||||
|
||||
// 视频内容审核
|
||||
// 参考文档:https://developer.qiniu.com/censor/api/5620/video-censor
|
||||
|
||||
$body = '{
|
||||
"data":{
|
||||
"uri":"https://dn-mars-assets.qbox.me/Fi1UC6waXtXYCpnTGHa8XxIziGNk"
|
||||
},
|
||||
"params":{
|
||||
"scenes":[
|
||||
"pulp",
|
||||
"terror",
|
||||
"politician",
|
||||
"ads"
|
||||
]
|
||||
}
|
||||
}';
|
||||
|
||||
list($jobid, $err) = $argusManager->censorVideo($body);
|
||||
echo "\n====> Result is: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "job_id is: $jobid\n";
|
||||
}
|
||||
|
||||
// 查询视频审核结果
|
||||
list($ret, $err) = $argusManager->censorStatus($jobid);
|
||||
echo "\n====> job status: \n";
|
||||
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/delete_bucket.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/delete_bucket.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 删除指定的 Bucket
|
||||
// 1、空间绑定了自定义域名,禁止删除,需要先解绑域名
|
||||
// 2、空间不为空,禁止删除,需要先把空间内的文件删除完毕
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->deleteBucket($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
28
vendor/qiniu/php-sdk/examples/delete_bucketEvent.php
vendored
Normal file
28
vendor/qiniu/php-sdk/examples/delete_bucketEvent.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 删除 bucket 事件通知规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
$name = 'demo'; // 规则名称 bucket 内唯一,由 1 ~ 50 个字符组成,可包含:字母、数字和下划线
|
||||
|
||||
list($ret, $err) = $bucketManager->deleteBucketEvent($bucket, $name);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/delete_bucketLifecycleRule.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/delete_bucketLifecycleRule.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 删除存储空间 - 生命周期规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
$name = 'demo'; // 生命周期规则名称
|
||||
|
||||
list($ret, $err) = $bucketManager->deleteBucketLifecycleRule($bucket, $name);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_bucketEvents.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_bucketEvents.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取存储空间 - 事件通知规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->getBucketEvents($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_bucketLifecycleRules.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_bucketLifecycleRules.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取存储空间 - 生命周期规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->getBucketLifecycleRules($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_bucketList.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_bucketList.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 列举空间,返回 bucket 列表
|
||||
// 存储区域参考文档:https://developer.qiniu.com/kodo/manual/1671/region-endpoint
|
||||
|
||||
$region = 'z1'; // 华东:z0,华北:z1,华南:z2,北美:na0,东南亚:as0
|
||||
|
||||
list($ret, $err) = $bucketManager->listbuckets($region);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_bucketQuota.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_bucketQuota.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取用户 bucket 配额限制
|
||||
// size 表示空间存储量配额,count 表示空间文件数配额,新创建的空间默认没有限额
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->getBucketQuota($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
25
vendor/qiniu/php-sdk/examples/get_bucketinfo.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/get_bucketinfo.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取指定空间的相关信息
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->bucketInfo($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_bucketinfos.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_bucketinfos.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取指定 zone(存储区域)的空间信息列表
|
||||
// 存储区域,参考文档:https://developer.qiniu.com/kodo/manual/1671/region-endpoint
|
||||
|
||||
$region = 'z1'; // 华东:z0,华北:z1,华南:z2,北美:na0,东南亚:as0
|
||||
|
||||
list($ret, $err) = $bucketManager->bucketInfos($region);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/get_corsRules.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/get_corsRules.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取 bucket 设置的跨域信息
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6094/set-cors
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
|
||||
list($ret, $err) = $bucketManager->getCorsRules($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
74
vendor/qiniu/php-sdk/examples/image_url_builder.php
vendored
Normal file
74
vendor/qiniu/php-sdk/examples/image_url_builder.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
// 引入图片处理类
|
||||
use Qiniu\Processing\ImageUrlBuilder;
|
||||
|
||||
$imageUrlBuilder = new ImageUrlBuilder();
|
||||
|
||||
// 要处理的图片
|
||||
$url = 'http://78re52.com1.z0.glb.clouddn.com/resource/gogopher.jpg';
|
||||
$url2 = 'http://78re52.com1.z0.glb.clouddn.com/resource/gogopher.jpg?watermark/1/gravity/SouthEast/dx/0/dy/0/image/'
|
||||
. 'aHR0cDovL2Fkcy1jZG4uY2h1Y2h1amllLmNvbS9Ga1R6bnpIY2RLdmRBUFc5cHZZZ3pTc21UY0tB';
|
||||
$waterImage = 'http://developer.qiniu.com/resource/logo-2.jpg';
|
||||
|
||||
/**
|
||||
* 缩略图链接拼接
|
||||
*
|
||||
* @param string $url 图片链接
|
||||
* @param int $mode 缩略模式
|
||||
* @param int $width 宽度
|
||||
* @param int $height 长度
|
||||
* @param string $format 输出类型 [可选]
|
||||
* @param int $quality 图片质量 [可选]
|
||||
* @param int $interlace 是否支持渐进显示 [可选]
|
||||
* @param int $ignoreError 忽略结果 [可选]
|
||||
* @return string
|
||||
* @link http://developer.qiniu.com/code/v6/api/kodo-api/image/imageview2.html
|
||||
* @author Sherlock Ren <sherlock_ren@icloud.com>
|
||||
*/
|
||||
$thumbLink = $imageUrlBuilder->thumbnail($url, 1, 100, 100);
|
||||
|
||||
// 函数方式调用 也可拼接多个操作参数 图片+水印
|
||||
$thumbLink2 = \Qiniu\thumbnail($url2, 1, 100, 100);
|
||||
var_dump($thumbLink, $thumbLink2);
|
||||
|
||||
/**
|
||||
* 图片水印
|
||||
*
|
||||
* @param string $url 图片链接
|
||||
* @param string $image 水印图片链接
|
||||
* @param int $dissolve 透明度 [可选]
|
||||
* @param string $gravity 水印位置 [可选]
|
||||
* @param int $dx 横轴边距 [可选]
|
||||
* @param int $dy 纵轴边距 [可选]
|
||||
* @param int $watermarkScale 自适应原图的短边比例 [可选]
|
||||
* @link https://developer.qiniu.com/dora/api/1316/image-watermarking-processing-watermark
|
||||
* @return string
|
||||
* @author Sherlock Ren <sherlock_ren@icloud.com>
|
||||
*/
|
||||
$waterLink = $imageUrlBuilder->waterImg($url, $waterImage);
|
||||
// 函数调用方法
|
||||
//$waterLink = \Qiniu\waterImg($url, $waterImage);
|
||||
var_dump($waterLink);
|
||||
|
||||
/**
|
||||
* 文字水印
|
||||
*
|
||||
* @param string $url 图片链接
|
||||
* @param string $text 文字
|
||||
* @param string $font 文字字体
|
||||
* @param string $fontSize 文字字号
|
||||
* @param string $fontColor 文字颜色 [可选]
|
||||
* @param int $dissolve 透明度 [可选]
|
||||
* @param string $gravity 水印位置 [可选]
|
||||
* @param int $dx 横轴边距 [可选]
|
||||
* @param int $dy 纵轴边距 [可选]
|
||||
* @link http://developer.qiniu.com/code/v6/api/kodo-api/image/watermark.html#text-watermark
|
||||
* @return string
|
||||
* @author Sherlock Ren <sherlock_ren@icloud.com>
|
||||
*/
|
||||
$textLink = $imageUrlBuilder->waterText($url, '你瞅啥', '微软雅黑', 300);
|
||||
// 函数调用方法
|
||||
// $textLink = \Qiniu\waterText($url, '你瞅啥', '微软雅黑', 300);
|
||||
var_dump($textLink);
|
||||
18
vendor/qiniu/php-sdk/examples/persistent_fop_init.php
vendored
Normal file
18
vendor/qiniu/php-sdk/examples/persistent_fop_init.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$config->useHTTPS=true;
|
||||
|
||||
// 初始化
|
||||
$pfop = new PersistentFop($auth, $config);
|
||||
19
vendor/qiniu/php-sdk/examples/persistent_fop_status.php
vendored
Normal file
19
vendor/qiniu/php-sdk/examples/persistent_fop_status.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
$pfop = new Qiniu\Processing\PersistentFop(null, null);
|
||||
|
||||
// 通过 persistentId 来主动查询持久化处理(prefop)的执行状态
|
||||
// 参考文档:https://developer.qiniu.com/dora/api/1294/persistent-processing-status-query-prefop
|
||||
|
||||
// 触发持久化处理后返回的 persistentId
|
||||
$persistentId = 'z2.01z201c4oyre6q1hgy00murnel0002nh';
|
||||
|
||||
list($ret, $err) = $pfop->status($persistentId);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
58
vendor/qiniu/php-sdk/examples/pfop_mkzip.php
vendored
Normal file
58
vendor/qiniu/php-sdk/examples/pfop_mkzip.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 将七牛存储空间中的资源进行批量压缩
|
||||
// 参考文档:https://developer.qiniu.com/dora/api/1667/mkzip
|
||||
|
||||
// 要压缩的文件所在的空间和文件名
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$key = 'qiniu.png';
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
$pfop = new PersistentFop($auth, null);
|
||||
|
||||
// 进行 zip 压缩的 url
|
||||
$url1 = 'http://phpsdk.qiniudn.com/php-logo.png';
|
||||
$url2 = 'http://phpsdk.qiniudn.com/1.png';
|
||||
|
||||
// 压缩后的 key
|
||||
$zipKey = 'test.zip';
|
||||
|
||||
$fops = 'mkzip/2/url/' . \Qiniu\base64_urlSafeEncode($url1);
|
||||
$fops .= '/url/' . \Qiniu\base64_urlSafeEncode($url2);
|
||||
$fops .= '|saveas/' . \Qiniu\base64_urlSafeEncode("$bucket:$zipKey");
|
||||
|
||||
// 处理完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
$notify_url = null;
|
||||
|
||||
// 当转码后的文件名与源文件名相同时,是否覆盖源文件
|
||||
$force = false;
|
||||
|
||||
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notify_url, $force);
|
||||
|
||||
echo "\n====> pfop mkzip result: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "PersistentFop Id: $id\n";
|
||||
}
|
||||
|
||||
// 查询转码的进度和状态
|
||||
list($ret, $err) = $pfop->status($id);
|
||||
echo "\n====> pfop mkzip status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
55
vendor/qiniu/php-sdk/examples/pfop_vframe.php
vendored
Normal file
55
vendor/qiniu/php-sdk/examples/pfop_vframe.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 对已经上传到七牛的视频发起异步转码操作
|
||||
// 视频帧缩略图参考文档:https://developer.qiniu.com/dora/api/1313/video-frame-thumbnails-vframe
|
||||
|
||||
// 要转码的文件所在的空间和文件名
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$key = 'qiniu.mp4';
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
// 转码完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
|
||||
|
||||
// 当转码后的文件名与源文件名相同时,是否覆盖源文件
|
||||
$force = false;
|
||||
|
||||
$config = new Config();
|
||||
$config->useHTTPS = true;
|
||||
$pfop = new PersistentFop($auth, $config);
|
||||
|
||||
// 视频处理完毕后保存到空间中的名称
|
||||
$saveasKey = 'qiniu_480x360.jpg';
|
||||
|
||||
// 进行视频截帧操作
|
||||
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90|saveas/" .
|
||||
\Qiniu\base64_urlSafeEncode("$bucket:$saveasKey");
|
||||
|
||||
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
|
||||
echo "\n====> pfop avthumb result: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "PersistentFop Id: $id\n";
|
||||
}
|
||||
|
||||
// 查询转码的进度和状态
|
||||
list($ret, $err) = $pfop->status($id);
|
||||
echo "\n====> pfop avthumb status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
55
vendor/qiniu/php-sdk/examples/pfop_video_avthumb.php
vendored
Normal file
55
vendor/qiniu/php-sdk/examples/pfop_video_avthumb.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 对已经上传到七牛的视频发起异步转码操作
|
||||
// 普通音视频转码参考文档:https://developer.qiniu.com/dora/api/1248/audio-and-video-transcoding-avthumb
|
||||
|
||||
// 要转码的文件所在的空间和文件名。
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$key = 'qiniu.mp4';
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
// 当转码后的文件名与源文件名相同时,是否覆盖源文件
|
||||
$force = false;
|
||||
|
||||
// 转码完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
|
||||
$config = new Config();
|
||||
$config->useHTTPS=true;
|
||||
|
||||
// 视频处理完毕后保存到空间中的名称
|
||||
$saveasKey = 'qiniu_640x360.mp4';
|
||||
|
||||
$pfop = new PersistentFop($auth, $config);
|
||||
|
||||
// 进行视频转码操作
|
||||
$fops = "avthumb/mp4/s/640x360/vb/1.4m|saveas/" . \Qiniu\base64_urlSafeEncode("$bucket:$saveasKey");
|
||||
|
||||
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
|
||||
echo "\n====> pfop avthumb result: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "PersistentFop Id: $id\n";
|
||||
}
|
||||
|
||||
// 查询转码的进度和状态
|
||||
list($ret, $err) = $pfop->status($id);
|
||||
echo "\n====> pfop avthumb status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
59
vendor/qiniu/php-sdk/examples/pfop_watermark.php
vendored
Normal file
59
vendor/qiniu/php-sdk/examples/pfop_watermark.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 对已经上传到七牛的视频发起异步转码操作
|
||||
// 视频水印参考文档:https://developer.qiniu.com/dora/api/1314/video-watermarking
|
||||
|
||||
// 要转码的文件所在的空间和文件名
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$key = 'qiniu.mp4';
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
// 转码完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
|
||||
|
||||
// 当转码后的文件名与源文件名相同时,是否覆盖源文件
|
||||
$force = false;
|
||||
|
||||
$config = new Config();
|
||||
$config->useHTTPS=true;
|
||||
$pfop = new PersistentFop($auth, $config);
|
||||
|
||||
// 图片水印的源路径,也就是给视频打图片水印的图片
|
||||
$base64URL = Qiniu\base64_urlSafeEncode('http://test-2.qiniudn.com/logo.png');
|
||||
|
||||
// 视频处理完毕后保存到空间中的名称
|
||||
$saveasKey = 'qiniu_watermark.mp4';
|
||||
|
||||
// 进行视频打图片水印操作
|
||||
$fops = "avthumb/mp4/wmImage/" . $base64URL . "|saveas/"
|
||||
. \Qiniu\base64_urlSafeEncode("$bucket:$saveasKey");
|
||||
|
||||
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
|
||||
echo "\n====> pfop avthumb result: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "PersistentFop Id: $id\n";
|
||||
}
|
||||
|
||||
// 查询转码的进度和状态
|
||||
list($ret, $err) = $pfop->status($id);
|
||||
echo "\n====> pfop avthumb status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
BIN
vendor/qiniu/php-sdk/examples/php-logo.png
vendored
Normal file
BIN
vendor/qiniu/php-sdk/examples/php-logo.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
27
vendor/qiniu/php-sdk/examples/prefop.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/prefop.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$config->useHTTPS=true;
|
||||
|
||||
$pfop = new PersistentFop($auth, $config);
|
||||
|
||||
$id = "z2.01z201c4oyre6q1hgy00murnel0002nh";
|
||||
|
||||
// 查询持久化处理的进度和状态
|
||||
list($ret, $err) = $pfop->status($id);
|
||||
echo "\n====> pfop avthumb status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/put_bucketAccessMode.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/put_bucketAccessMode.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
$private = 1; // 公开:0,私有:1
|
||||
|
||||
// 设置 Bucket 访问权限
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/3946/set-bucket-private
|
||||
|
||||
list($ret, $err) = $bucketManager->putBucketAccessMode($bucket, $private);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/put_bucketAccessStyleMode.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/put_bucketAccessStyleMode.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
$bucket = 'xxxx'; // 存储空间名称
|
||||
$mode = 1; // 关闭:0 ,开启:1
|
||||
|
||||
// 存储空间 - 原图保护开关
|
||||
// 原图保护:https://developer.qiniu.com/kodo/kb/1359/what-is-the-original-protection
|
||||
|
||||
list($ret, $err) = $bucketManager->putBucketAccessStyleMode($bucket, $mode);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
32
vendor/qiniu/php-sdk/examples/put_bucketEvent.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/put_bucketEvent.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 增加 bucket 事件通知规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$name = 'testnotification';
|
||||
$prefix = 'test1';
|
||||
$suffix = 'mp3';
|
||||
$event = array("move","copy");
|
||||
$callbackURL = 'http://www.qiniu.com'; // 回调服务器地址,需要可以公网访问,并能够相应 200 OK
|
||||
|
||||
list($ret, $err) = $bucketManager->putBucketEvent($bucket, $name, $prefix, $suffix, $event, $callbackURL);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/put_bucketMaxAge.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/put_bucketMaxAge.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 设置 Bucket 的 maxAge
|
||||
// 参考文档:https://developer.qiniu.com/kodo/kb/1475/space-maxage-attribute-to-the-cache-control
|
||||
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$maxAge = 31536000;
|
||||
|
||||
list($ret, $err) = $bucketManager->putBucketMaxAge($bucket, $maxAge);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
29
vendor/qiniu/php-sdk/examples/put_bucketQuota.php
vendored
Normal file
29
vendor/qiniu/php-sdk/examples/put_bucketQuota.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 设置 bucket 配额
|
||||
// size 表示空间存储量配额,count 表示空间文件数配额,新创建的空间默认没有限额
|
||||
|
||||
$size = 99999;
|
||||
$count = 99;
|
||||
|
||||
list($ret, $err) = $bucketManager->putBucketQuota($bucket, $size, $count);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
30
vendor/qiniu/php-sdk/examples/put_referAntiLeech.php
vendored
Normal file
30
vendor/qiniu/php-sdk/examples/put_referAntiLeech.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 存储空间 - 设置 referer 防盗链
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6093/set-the-hotlinking-prevention
|
||||
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$mode = 1; // 关闭Referer(使用此选项将会忽略以下参数并将恢复默认值):0,设置Referer白名单:1,表示设置Referer黑名单:2
|
||||
$norefer = "1"; // 表示不允许空 Refer 访问:0,表示允许空 Refer 访问:1
|
||||
$pattern = "*.qiniu.com"; // 当前仅支持这三种格式:a.b.com,*.b.com,*
|
||||
|
||||
list($ret, $err) = $bucketManager->putReferAntiLeech($bucket, $mode, $norefer, $pattern);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
14
vendor/qiniu/php-sdk/examples/qetag.php
vendored
Normal file
14
vendor/qiniu/php-sdk/examples/qetag.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
use Qiniu\Etag;
|
||||
|
||||
// 计算文件的 ETag
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/1231/appendix#3
|
||||
|
||||
$localFile = "./php-logo.png";
|
||||
list($ret, $err) = Etag::sum($localFile);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "Etag: $ret";
|
||||
}
|
||||
71
vendor/qiniu/php-sdk/examples/rs_asynch_fetch.php
vendored
Normal file
71
vendor/qiniu/php-sdk/examples/rs_asynch_fetch.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$config->useHTTPS = true; // 接口是否使用 HTTPS 协议
|
||||
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 异步第三方资源抓取
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/4097/asynch-fetch
|
||||
|
||||
// 需要抓取的文件 URL
|
||||
$url = 'http://devtools.qiniu.com/qiniu.png';
|
||||
|
||||
//回调 URL(需要可以公网访问,并能够相应 200 OK)
|
||||
$callbackurl = "http://your.domain.com/upload_verify_callback.php";
|
||||
|
||||
// 回调Body
|
||||
$callbackbody = '{"key":"$(key)","hash":"$(etag)","w":"$(imageInfo.width)","h":"$(imageInfo.height)"}';
|
||||
|
||||
|
||||
//---------------------------------------- demo1 ----------------------------------------
|
||||
// 指定抓取的文件保存到七牛云空间中的名称
|
||||
|
||||
$key = time() . '.png';
|
||||
list($ret, $err) = $bucketManager->asynchFetch($url, $bucket, null, $key, null, null, $callbackurl, $callbackbody);
|
||||
echo "=====> asynch fetch $url to bucket: $bucket key: $key\n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
$id = $ret['id'];
|
||||
echo "id is: $id\n";
|
||||
}
|
||||
|
||||
//---------------------------------------- demo2 ----------------------------------------
|
||||
// 不指定 key 时,以文件内容的 hash 作为文件名
|
||||
|
||||
$key = null;
|
||||
list($ret, $err) = $bucketManager->asynchFetch($url, $bucket, null, $key, null, null, $callbackurl, $callbackbody);
|
||||
echo "=====> asynch fetch $url to bucket: $bucket key: $(etag)\n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
$id = $ret['id'];
|
||||
echo "id is: $id\n";
|
||||
}
|
||||
|
||||
// 查询异步抓取的进度和状态
|
||||
|
||||
// 华东:z0,华北:z1,华南:z2,北美:na0,东南亚:as0
|
||||
$zone = 'z2';
|
||||
|
||||
sleep(10); // 由于异步抓取需要耗时,等待 10 秒后再查询状态
|
||||
list($ret, $err) = $bucketManager->asynchFetchStatus($zone, $id);
|
||||
echo "\n====> asynch fetch status: \n";
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
32
vendor/qiniu/php-sdk/examples/rs_batch_change_mime.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/rs_batch_change_mime.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量修改文件类型,每次最多不能超过 1000 个
|
||||
|
||||
$keyMimePairs = array(
|
||||
'qiniu.mp4' => 'video/x-mp4',
|
||||
'qiniu.png' => 'image/x-png',
|
||||
'qiniu.jpg' => 'image/x-jpg'
|
||||
);
|
||||
|
||||
$ops = $bucketManager->buildBatchChangeMime($bucket, $keyMimePairs);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
39
vendor/qiniu/php-sdk/examples/rs_batch_change_type.php
vendored
Normal file
39
vendor/qiniu/php-sdk/examples/rs_batch_change_type.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量修改文件存储类型,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$keyTypePairs = array();
|
||||
|
||||
// type=0表示普通存储,type=1表示低频存储
|
||||
foreach ($keys as $key) {
|
||||
$keyTypePairs[$key] = 1;
|
||||
}
|
||||
|
||||
$ops = $bucketManager->buildBatchChangeType($bucket, $keyTypePairs);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
40
vendor/qiniu/php-sdk/examples/rs_batch_copy.php
vendored
Normal file
40
vendor/qiniu/php-sdk/examples/rs_batch_copy.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量复制文件到另一个存储空间,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$keyPairs = array();
|
||||
foreach ($keys as $key) {
|
||||
$keyPairs[$key] = $key . "_copy";
|
||||
}
|
||||
|
||||
$srcBucket = $bucket;
|
||||
$destBucket = $bucket;
|
||||
|
||||
$ops = $bucketManager->buildBatchCopy($srcBucket, $keyPairs, $destBucket, true);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
32
vendor/qiniu/php-sdk/examples/rs_batch_delete.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/rs_batch_delete.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量删除文件,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$ops = $bucketManager->buildBatchDelete($bucket, $keys);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
39
vendor/qiniu/php-sdk/examples/rs_batch_delete_after_days.php
vendored
Normal file
39
vendor/qiniu/php-sdk/examples/rs_batch_delete_after_days.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量修改文件生命周期,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$keyDayPairs = array();
|
||||
|
||||
// day=0表示永久存储
|
||||
foreach ($keys as $key) {
|
||||
$keyDayPairs[$key] = 0;
|
||||
}
|
||||
|
||||
$ops = $bucketManager->buildBatchDeleteAfterDays($bucket, $keyDayPairs);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
40
vendor/qiniu/php-sdk/examples/rs_batch_move.php
vendored
Normal file
40
vendor/qiniu/php-sdk/examples/rs_batch_move.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量移动文件到另一个存储空间,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$keyPairs = array();
|
||||
foreach ($keys as $key) {
|
||||
$keyPairs[$key . "_copy"] = $key . "_move";
|
||||
}
|
||||
|
||||
$srcBucket = $bucket;
|
||||
$destBucket = $bucket;
|
||||
|
||||
$ops = $bucketManager->buildBatchMove($srcBucket, $keyPairs, $destBucket, true);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
32
vendor/qiniu/php-sdk/examples/rs_batch_stat.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/rs_batch_stat.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 批量查询文件状态,每次最多不能超过 1000 个
|
||||
|
||||
$keys = array(
|
||||
'qiniu.mp4',
|
||||
'qiniu.png',
|
||||
'qiniu.jpg'
|
||||
);
|
||||
|
||||
$ops = $bucketManager->buildBatchStat($bucket, $keys);
|
||||
list($ret, $err) = $bucketManager->batch($ops);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/rs_bucket_domains.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/rs_bucket_domains.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取指定空间绑定的所有的域名
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/3949/get-the-bucket-space-domain
|
||||
|
||||
list($ret, $err) = $bucketManager->domains($bucket);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
25
vendor/qiniu/php-sdk/examples/rs_buckets.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/rs_buckets.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 获取指定账号下所有的空间名
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/3926/get-service
|
||||
|
||||
list($ret, $err) = $bucketManager->buckets(true);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/rs_change_mime.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/rs_change_mime.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 修改文件的 MIME 类型信息
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1252/chgm
|
||||
|
||||
$key = 'qiniu.mp4';
|
||||
$newMime = 'video/x-mp4';
|
||||
|
||||
$err = $bucketManager->changeMime($bucket, $key, $newMime);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/rs_change_status.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/rs_change_status.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
$status = 1;// 启用:0,禁用:1
|
||||
|
||||
// 修改文件的存储状态。参考文档:https://developer.qiniu.com/kodo/api/4173/modify-the-file-status
|
||||
|
||||
$key = "qiniu.jpg";
|
||||
|
||||
$err = $bucketManager->changeStatus($bucket, $key, $status);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
29
vendor/qiniu/php-sdk/examples/rs_change_type.php
vendored
Normal file
29
vendor/qiniu/php-sdk/examples/rs_change_type.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
|
||||
|
||||
// 修改指定资源的存储类型
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/3710/chtype
|
||||
|
||||
$key = "qiniu.mp4";
|
||||
$fileType = 1; // 0 表示标准存储;1 表示低频存储;2 表示归档存储
|
||||
|
||||
$err = $bucketManager->changeType($bucket, $key, $fileType);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/rs_copy.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/rs_copy.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 资源复制
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1254/copy
|
||||
|
||||
$key = "qiniu.mp4";
|
||||
|
||||
$srcBucket = $bucket;
|
||||
$destBucket = $bucket;
|
||||
$srcKey = $key;
|
||||
$destKey = $key . "_copy";
|
||||
|
||||
$err = $bucketManager->copy($srcBucket, $srcKey, $destBucket, $destKey, true);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
25
vendor/qiniu/php-sdk/examples/rs_delete.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/rs_delete.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 删除指定资源,参考文档:https://developer.qiniu.com/kodo/api/1257/delete
|
||||
|
||||
$key = "qiniu.mp4_copy";
|
||||
|
||||
$err = $bucketManager->delete($bucket, $key);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
24
vendor/qiniu/php-sdk/examples/rs_delete_after_days.php
vendored
Normal file
24
vendor/qiniu/php-sdk/examples/rs_delete_after_days.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new \Qiniu\Config();
|
||||
$bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
|
||||
|
||||
// 设置文件的生命周期
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1732/update-file-lifecycle
|
||||
|
||||
$key = 'qiniu.mp4';
|
||||
$days = 10; // 设置为 0 表示取消生命周期
|
||||
|
||||
$err = $bucketManager->deleteAfterDays($bucket, $key, $days);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
19
vendor/qiniu/php-sdk/examples/rs_download_urls.php
vendored
Normal file
19
vendor/qiniu/php-sdk/examples/rs_download_urls.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
// 构建 Auth 对象
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 私有空间中的外链 http(s)://<domain>/<file_key>,一定要带访问协议,也就是 http:// 或者 https://
|
||||
$baseUrl = 'http://if-pri.qiniudn.com/qiniu.png?imageView2/1/h/500';
|
||||
|
||||
// 对链接进行签名,参考文档:https://developer.qiniu.com/kodo/manual/1656/download-private
|
||||
$signedUrl = $auth->privateDownloadUrl($baseUrl);
|
||||
|
||||
echo $signedUrl;
|
||||
43
vendor/qiniu/php-sdk/examples/rs_fetch.php
vendored
Normal file
43
vendor/qiniu/php-sdk/examples/rs_fetch.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$bucketManager = new BucketManager($auth);
|
||||
|
||||
// 第三方资源抓取
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1263/fetch
|
||||
|
||||
// 需要抓取的文件 URL
|
||||
$url = 'http://devtools.qiniu.com/qiniu.png';
|
||||
|
||||
//---------------------------------------- demo1 ----------------------------------------
|
||||
// 指定抓取的文件保存到七牛云空间中的名称
|
||||
|
||||
$key = time() . '.png';
|
||||
list($ret, $err) = $bucketManager->fetch($url, $bucket, $key);
|
||||
echo "=====> fetch $url to bucket: $bucket key: $key\n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
print_r($ret);
|
||||
}
|
||||
|
||||
//---------------------------------------- demo2 ----------------------------------------
|
||||
// 不指定 key 时,以文件内容的 hash 作为文件名
|
||||
|
||||
$key = null;
|
||||
list($ret, $err) = $bucketManager->fetch($url, $bucket, $key);
|
||||
echo "=====> fetch $url to bucket: $bucket key: $(etag)\n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
print_r($ret);
|
||||
}
|
||||
27
vendor/qiniu/php-sdk/examples/rs_move.php
vendored
Normal file
27
vendor/qiniu/php-sdk/examples/rs_move.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$key = "qiniu.mp4";
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new \Qiniu\Config();
|
||||
$bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
|
||||
|
||||
$srcBucket = $bucket;
|
||||
$destBucket = $bucket;
|
||||
$srcKey = $key . "_copy";
|
||||
$destKey = $key . "_move";
|
||||
|
||||
// 资源移动或者重命名
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1288/move
|
||||
|
||||
$err = $bucketManager->move($srcBucket, $srcKey, $destBucket, $destKey, true);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
23
vendor/qiniu/php-sdk/examples/rs_prefetch.php
vendored
Normal file
23
vendor/qiniu/php-sdk/examples/rs_prefetch.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$key = "qiniu.mp4";
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new \Qiniu\Config();
|
||||
$bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
|
||||
|
||||
// 镜像资源更新
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1293/prefetch
|
||||
|
||||
$err = $bucketManager->prefetch($bucket, $key);
|
||||
if ($err) {
|
||||
print_r($err);
|
||||
}
|
||||
28
vendor/qiniu/php-sdk/examples/rs_stat.php
vendored
Normal file
28
vendor/qiniu/php-sdk/examples/rs_stat.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 资源元信息查询
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1308/stat
|
||||
|
||||
$key = "qiniu.mp4";
|
||||
|
||||
list($ret, $err) = $bucketManager->stat($bucket, $key);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
47
vendor/qiniu/php-sdk/examples/rsf_list_bucket.php
vendored
Normal file
47
vendor/qiniu/php-sdk/examples/rsf_list_bucket.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$bucketManager = new BucketManager($auth);
|
||||
|
||||
// 资源列举
|
||||
// 参考文档:https://developer.qiniu.com/kodo/api/1284/list
|
||||
|
||||
// 要列取文件的公共前缀
|
||||
$prefix = '';
|
||||
|
||||
// 上次列举返回的位置标记,作为本次列举的起点信息。
|
||||
$marker = '';
|
||||
|
||||
// 本次列举的条目数,范围为 1-1000
|
||||
$limit = 200;
|
||||
|
||||
$delimiter = '/';
|
||||
|
||||
do {
|
||||
list($ret, $err) = $bucketManager->listFiles($bucket, $prefix, $marker, $limit, $delimiter);
|
||||
if ($err !== null) {
|
||||
echo "\n====> list file err: \n";
|
||||
var_dump($err);
|
||||
} else {
|
||||
$marker = null;
|
||||
if (array_key_exists('marker', $ret)) {
|
||||
$marker = $ret['marker'];
|
||||
}
|
||||
echo "Marker: $marker\n";
|
||||
echo "\nList Items====>\n";
|
||||
//var_dump($ret['items']);
|
||||
print('items count:' . count($ret['items']) . "\n");
|
||||
if (array_key_exists('commonPrefixes', $ret)) {
|
||||
print_r($ret['commonPrefixes']);
|
||||
}
|
||||
}
|
||||
} while (!empty($marker));
|
||||
39
vendor/qiniu/php-sdk/examples/rsf_list_files.php
vendored
Normal file
39
vendor/qiniu/php-sdk/examples/rsf_list_files.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$bucketManager = new BucketManager($auth);
|
||||
|
||||
// 资源列举
|
||||
// https://developer.qiniu.com/kodo/api/1284/list
|
||||
|
||||
// 要列取文件的公共前缀
|
||||
$prefix = '';
|
||||
|
||||
// 上次列举返回的位置标记,作为本次列举的起点信息。
|
||||
$marker = '';
|
||||
|
||||
// 本次列举的条目数,,范围为 1-1000
|
||||
$limit = 100;
|
||||
|
||||
$delimiter = '/';
|
||||
|
||||
// 列举文件
|
||||
list($ret, $err) = $bucketManager->listFiles($bucket, $prefix, $marker, $limit, $delimiter);
|
||||
if ($err !== null) {
|
||||
echo "\n====> list file err: \n";
|
||||
var_dump($err);
|
||||
} else {
|
||||
if (array_key_exists('marker', $ret)) {
|
||||
echo "Marker:" . $ret["marker"] . "\n";
|
||||
}
|
||||
echo "\nList Iterms====>\n";
|
||||
}
|
||||
34
vendor/qiniu/php-sdk/examples/rsf_v2list_bucket.php
vendored
Normal file
34
vendor/qiniu/php-sdk/examples/rsf_v2list_bucket.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$bucketManager = new BucketManager($auth);
|
||||
|
||||
// 资源列举 V2
|
||||
// https://developer.qiniu.com/kodo/api/4539/v2-list
|
||||
|
||||
// 要列取文件的公共前缀
|
||||
$prefix = '';
|
||||
|
||||
// 上次列举返回的位置标记,作为本次列举的起点信息。
|
||||
$marker = '';
|
||||
|
||||
// 本次列举的条目数,范围为 1-1000
|
||||
$limit = 1000;
|
||||
|
||||
$delimiter = '';
|
||||
|
||||
list($ret, $err) = $bucketManager->listFilesv2($bucket, $prefix, $marker, $limit, $delimiter, true);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
34
vendor/qiniu/php-sdk/examples/rtc/README.md
vendored
Normal file
34
vendor/qiniu/php-sdk/examples/rtc/README.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# Rtc Streaming Cloud Server-Side Library For PHP
|
||||
|
||||
## Features
|
||||
|
||||
- RoomToken 签发
|
||||
- [x] 生成 RoomToken: client->appToken()
|
||||
|
||||
- App 管理
|
||||
- [x] 创建应用: client->createApp()
|
||||
- [x] 获取应用配置信息: client->getApp()
|
||||
- [x] 更新应用配置信息: client->updateApp()
|
||||
- [x] 删除应用: client->deleteApp()
|
||||
|
||||
- 房间管理
|
||||
- [x] 列举房间下的所有用户: client->listUser()
|
||||
- [x] 指定一个用户踢出房间: client->kickUser()
|
||||
- [x] 停止一个房间的合流转推: client->stopMerge()
|
||||
- [x] 获取当前所有活跃的房间: client->listActiveRooms()
|
||||
|
||||
## Demo
|
||||
- RoomToken 签发
|
||||
- [生成 RoomToken](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_create_roomToken.php)
|
||||
|
||||
- App 管理
|
||||
- [创建应用](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_createApp.php)
|
||||
- [获取应用配置信息](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_getApp.php)
|
||||
- [更新应用配置信息](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_updateApp.php)
|
||||
- [删除应用](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_deleteApp.php)
|
||||
|
||||
- 房间管理
|
||||
- [列举房间下的所有用户](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_listUser.php)
|
||||
- [指定一个用户踢出房间](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_kickUser.php)
|
||||
- [停止一个房间的合流转推](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_stopMerge.php)
|
||||
- [获取当前所有活跃的房间](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_listActiveRooms.php)
|
||||
32
vendor/qiniu/php-sdk/examples/rtc/rtc_createApp.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/rtc/rtc_createApp.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// 绑定的直播hub,使用此hub的资源进行推流等业务功能,hub与app必须属于同一个七牛账户
|
||||
$hub = 'rtchub';
|
||||
|
||||
// app 的名称,注意:Title 不是唯一标识,重复 create 动作将生成多个 app
|
||||
$title = 'rtc';
|
||||
|
||||
// 连麦房间支持的最大在线人数
|
||||
$maxUsers = 20;
|
||||
|
||||
// 创建应用
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_1
|
||||
|
||||
list($ret, $err) = $client->createApp($hub, $title, $maxUsers);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Create Successfully: \n";
|
||||
var_dump($ret);
|
||||
}
|
||||
34
vendor/qiniu/php-sdk/examples/rtc/rtc_create_roomToken.php
vendored
Normal file
34
vendor/qiniu/php-sdk/examples/rtc/rtc_create_roomToken.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 房间名称,需满足规格 ^[a-zA-Z0-9_-]{3,64}$
|
||||
$roomName = 'room01';
|
||||
|
||||
// 请求加入房间的用户 ID,需满足规格 ^[a-zA-Z0-9_-]{3,50}$
|
||||
$userId = '001';
|
||||
|
||||
// 鉴权的有效时间,传入以秒为单位的64位 Unix 绝对时间,token 将在该时间后失效
|
||||
$expireAt = time()+3600;
|
||||
|
||||
// "admin"或"user",默认为"user" 。当权限角色为"admin"时,拥有将其他用户移除出房间等特权
|
||||
$permission = 'admin';
|
||||
|
||||
// 生成加入房间的令牌 RoomToken
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#1
|
||||
|
||||
$RoomToken = $client->appToken($appId, $roomName, $userId, $expireAt, $permission);
|
||||
echo "\n====> Create RoomToken Successfully: \n";
|
||||
var_dump($RoomToken);
|
||||
25
vendor/qiniu/php-sdk/examples/rtc/rtc_deleteApp.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/rtc/rtc_deleteApp.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 删除应用
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_1
|
||||
|
||||
list($ret, $err) = $client->deleteApp($appId);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Delete $appId Successfully \n";
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/rtc/rtc_getApp.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/rtc/rtc_getApp.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 获取一个应用当前的配置信息
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_1
|
||||
|
||||
list($ret, $err) = $client->getApp($appId);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> $appId Conf: \n";
|
||||
var_dump($ret);
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_kickUser.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_kickUser.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 房间名称
|
||||
$roomName = 'room01';
|
||||
|
||||
// 操作所剔除的用户
|
||||
$userId = '001';
|
||||
|
||||
// 指定一个用户踢出房间
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_2
|
||||
|
||||
list($ret, $err) = $client->kickUser($appId, $roomName, $userId);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Kick User $userId Successfully \n";
|
||||
}
|
||||
35
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_listActiveRooms.php
vendored
Normal file
35
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_listActiveRooms.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 所查询房间名的前缀索引,可以为空
|
||||
$prefix = null;
|
||||
|
||||
// 分页查询的位移标记
|
||||
$offset = null;
|
||||
|
||||
// 此次查询的最大长度
|
||||
$limit = 100;
|
||||
|
||||
// 获取当前所有活跃的房间
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_2
|
||||
|
||||
list($ret, $err) = $client->listActiveRooms($appId, $prefix, $offset, $limit);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Active Rooms:\n";
|
||||
var_dump($ret);
|
||||
}
|
||||
29
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_listUser.php
vendored
Normal file
29
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_listUser.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 房间名称
|
||||
$roomName = 'room01';
|
||||
|
||||
// 列出指定房间下当前所有用户
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_2
|
||||
|
||||
list($ret, $err) = $client->listUser($appId, $roomName);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> User List: \n";
|
||||
var_dump($ret);
|
||||
}
|
||||
28
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_stopMerge.php
vendored
Normal file
28
vendor/qiniu/php-sdk/examples/rtc/rtc_rooms_stopMerge.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成
|
||||
$appId = 'xxxx';
|
||||
|
||||
// 房间名称
|
||||
$roomName = 'room01';
|
||||
|
||||
// 停止一个房间的合流转推
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_2
|
||||
|
||||
list($ret, $err) = $client->stopMerge($appId, $roomName);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Stop Merge Successfully \n";
|
||||
}
|
||||
40
vendor/qiniu/php-sdk/examples/rtc/rtc_updateApp.php
vendored
Normal file
40
vendor/qiniu/php-sdk/examples/rtc/rtc_updateApp.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Rtc\AppClient;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new AppClient($auth);
|
||||
|
||||
// app 的唯一标识,创建的时候由系统生成。
|
||||
$appId = "xxxx";
|
||||
|
||||
// 绑定的直播hub,使用此hub的资源进行推流等业务功能,hub与app必须属于同一个七牛账户
|
||||
$hub = 'rtchub';
|
||||
|
||||
// app 的名称,注意:Title 不是唯一标识,重复 create 动作将生成多个 app
|
||||
$title = 'rtc';
|
||||
|
||||
// 连麦房间支持的最大在线人数
|
||||
$maxUsers = 30;
|
||||
|
||||
// 连麦合流转推 RTMP 的配置
|
||||
$mergePublishRtmp = array();
|
||||
$mergePublishRtmp['enable'] = true;
|
||||
|
||||
// 更新一个应用的配置信息
|
||||
// 注意:调用这个接口后仅对调用后新创建的房间有效,已经存在的房间需要等待被关闭重新创建后生效
|
||||
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_1
|
||||
|
||||
list($ret, $err) = $client->updateApp($appId, $hub, $title, $maxUsers, false, $mergePublishRtmp);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Update $appId Conf Successfully: \n";
|
||||
var_dump($ret);
|
||||
}
|
||||
33
vendor/qiniu/php-sdk/examples/saveas.php
vendored
Normal file
33
vendor/qiniu/php-sdk/examples/saveas.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Processing\PersistentFop;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
// 处理结果另存为
|
||||
// 参考文档:https://developer.qiniu.com/dora/api/1305/processing-results-save-saveas
|
||||
|
||||
// 生成EncodedEntryURI的值,<Key>为生成缩略图的文件名
|
||||
$entry = '<bucket>:<Key>';
|
||||
|
||||
// 生成的值
|
||||
$encodedEntryURI = \Qiniu\base64_urlSafeEncode($entry);
|
||||
|
||||
// 使用 SecretKey 对新的下载 URL 进行 HMAC1-SHA1 签名
|
||||
$newurl = "78re52.com1.z0.glb.clouddn.com/resource/Ship.jpg?imageView2/2/w/200/h/200|saveas/" . $encodedEntryURI;
|
||||
|
||||
$sign = hash_hmac("sha1", $newurl, $secretKey, true);
|
||||
|
||||
// 对签名进行 URL 安全的 Base64 编码
|
||||
$encodedSign = \Qiniu\base64_urlSafeEncode($sign);
|
||||
|
||||
// 最终得到的完整下载 URL
|
||||
$finalURL = "http://" . $newurl . "/sign/" . $accessKey . ":" . $encodedSign;
|
||||
|
||||
$callbackBody = file_get_contents("$finalURL");
|
||||
|
||||
echo $callbackBody;
|
||||
45
vendor/qiniu/php-sdk/examples/sms/README.md
vendored
Normal file
45
vendor/qiniu/php-sdk/examples/sms/README.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# SMS Server-Side Library For PHP
|
||||
|
||||
## Features
|
||||
|
||||
- 签名管理
|
||||
- [x] 创建签名: client->createSignature()
|
||||
- [x] 列出签名: client->checkSignature()
|
||||
- [x] 查询单个签名: client->checkSingleSignature()
|
||||
- [x] 编辑签名: client->updateSignature()
|
||||
- [x] 删除签名: client->deleteSignature()
|
||||
|
||||
- 模板管理
|
||||
- [x] 创建模板: client->createTemplate()
|
||||
- [x] 列出模板: client->queryTemplate()
|
||||
- [x] 查询单个模板: client->querySingleTemplate()
|
||||
- [x] 编辑模板: client->updateTemplate()
|
||||
- [x] 删除模板: client->deleteTemplate()
|
||||
|
||||
- 发送短信
|
||||
- [x] 发送短信: client->sendMessage()
|
||||
|
||||
- 查询发送记录
|
||||
- [x] 查询发送记录: client->querySendSms()
|
||||
|
||||
## Demo
|
||||
|
||||
- 签名管理
|
||||
- [创建签名](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_create_signature.php)
|
||||
- [列出签名](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_query_signature.php)
|
||||
- [查询单个签名](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_query_single_signature.php)
|
||||
- [编辑签名](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_edit_signature.php)
|
||||
- [删除签名](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_delete_signature.php)
|
||||
|
||||
- 模板管理
|
||||
- [创建模板](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_create_template.php)
|
||||
- [列出模板](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_query_template.php)
|
||||
- [查询单个模板](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_query_single_template.php)
|
||||
- [编辑模板](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_edit_template.php)
|
||||
- [删除模板](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_delete_template.php)
|
||||
|
||||
- 发送短信
|
||||
- [发送短信](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_send_message.php)
|
||||
|
||||
- 查询发送记录
|
||||
- [查询发送记录](https://github.com/qiniu/php-sdk/tree/master/examples/sms/sms_query_send_sms.php)
|
||||
29
vendor/qiniu/php-sdk/examples/sms/sms_create_signature.php
vendored
Normal file
29
vendor/qiniu/php-sdk/examples/sms/sms_create_signature.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 创建签名
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5844/sms-api-create-signature
|
||||
// 签名审核标准:https://developer.qiniu.com/sms/manual/5816/signature-specification
|
||||
|
||||
$signature = 'xxxx'; // 签名
|
||||
$source = 'website'; // 签名来源,申请签名时必须指定签名来源
|
||||
$pics = '../php-logo.png'; // 签名对应的资质证明图片
|
||||
|
||||
list($ret, $err) = $client->createSignature($signature, $source, $pics);
|
||||
|
||||
echo "\n====> create signature result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
33
vendor/qiniu/php-sdk/examples/sms/sms_create_template.php
vendored
Normal file
33
vendor/qiniu/php-sdk/examples/sms/sms_create_template.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 创建模板
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5893/sms-api-create-template
|
||||
// 模板审核标准:https://developer.qiniu.com/sms/manual/5814/template-specification
|
||||
|
||||
$name = 'xxxxxx'; // 模板名称
|
||||
$template = '您的验证码为: ${code},如非本人操作,请忽略本短信'; // 模板内容 可设置自定义变量,发送短信时候使用
|
||||
|
||||
// notification (通知类短信), verification (验证码短信), marketing (营销类短信), voice(语音类短信)
|
||||
$type = 'verification';
|
||||
$description = '发送验证码使用'; // 申请理由简述
|
||||
$signature_id = 'xxxxxx'; // 已经审核通过的签名
|
||||
|
||||
list($ret, $err) = $client->createTemplate($name, $template, $type, $description, $signature_id);
|
||||
|
||||
echo "\n====> create signature result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
25
vendor/qiniu/php-sdk/examples/sms/sms_delete_signature.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/sms/sms_delete_signature.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 删除签名
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5891/sms-api-delete-signature
|
||||
|
||||
// 签名 ID
|
||||
$signature_id = 'xxxxxx';
|
||||
|
||||
list($ret, $err) = $client->deleteSignature($signature_id);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Delete Signature $signature_id Successfully\n";
|
||||
}
|
||||
25
vendor/qiniu/php-sdk/examples/sms/sms_delete_template.php
vendored
Normal file
25
vendor/qiniu/php-sdk/examples/sms/sms_delete_template.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 删除模板
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5896/sms-api-delete-template
|
||||
|
||||
// 模板 ID
|
||||
$template_id = 'xxxxxx';
|
||||
|
||||
list($ret, $err) = $client->deleteTemplate($template_id);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Delete Template $template_id Successfully\n";
|
||||
}
|
||||
30
vendor/qiniu/php-sdk/examples/sms/sms_edit_signature.php
vendored
Normal file
30
vendor/qiniu/php-sdk/examples/sms/sms_edit_signature.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 编辑签名
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5890/sms-api-edit-signature
|
||||
// 签名审核标准:https://developer.qiniu.com/sms/manual/5816/signature-specification
|
||||
|
||||
$id = 'xxxxxx'; // 签名 ID
|
||||
$signature = 'xxxx'; // 签名
|
||||
$source = 'website'; // 签名来源,申请签名时必须指定签名来源
|
||||
$pics = '../php-logo.png'; // 签名对应的资质证明图片
|
||||
|
||||
list($ret, $err) = $client->updateSignature($id, $signature, $source, $pics);
|
||||
|
||||
echo "\n====> edit signature result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Update Signature Successfully\n";
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/sms/sms_edit_template.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/sms/sms_edit_template.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 编辑模板
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5895/sms-api-edit-template
|
||||
// 模板审核标准:https://developer.qiniu.com/sms/manual/5814/template-specification
|
||||
|
||||
$template_id = 'xxxxxx'; // 模板 ID
|
||||
$name = '验证码'; // 模板名称
|
||||
$template = '验证码为: ${code},如非本人操作,请忽略本短信'; // 模板内容 可设置自定义变量,发送短信时候使用
|
||||
$description = '发送验证码'; // 申请理由简述
|
||||
$signature_id = 'xxxxxx'; // 已经审核通过的签名
|
||||
|
||||
list($ret, $err) = $client->updateTemplate($template_id, $name, $template, $description, $signature_id);
|
||||
|
||||
echo "\n====> edit template result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Update Template Successfully\n";
|
||||
}
|
||||
50
vendor/qiniu/php-sdk/examples/sms/sms_query_send_sms.php
vendored
Normal file
50
vendor/qiniu/php-sdk/examples/sms/sms_query_send_sms.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 查询发送记录
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5852/query-send-sms
|
||||
|
||||
$job_id = 'xxxx'; // 发送任务返回的 id
|
||||
$message_id = 'xxxx'; // 单条短信发送接口返回的 id
|
||||
$mobile = 'xxxx'; // 接收短信的手机号码
|
||||
|
||||
// 短信的状态,sending: 发送中,success: 发送成功,failed: 发送失败,waiting: 等待发送
|
||||
$status = 'success';
|
||||
$template_id = 'xxxx'; // 模版 id
|
||||
|
||||
// marketing: 营销短信,notification: 通知短信,verification: 验证码类短信,voice: 语音短信
|
||||
$type = 'notification';
|
||||
|
||||
$start = 1599976580; // 开始时间
|
||||
$end = 1599977229; // 结束时间
|
||||
$page = 1; // 页码,默认为 1
|
||||
$page_size = 20; // 每页返回的数据条数,默认20,最大200
|
||||
|
||||
list($ret, $err) = $client->querySendSms(
|
||||
$job_id,
|
||||
$message_id,
|
||||
$mobile,
|
||||
$status,
|
||||
$template_id,
|
||||
$type,
|
||||
$start,
|
||||
$end,
|
||||
$page,
|
||||
$page_size
|
||||
);
|
||||
echo "\n====> query send sms result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
28
vendor/qiniu/php-sdk/examples/sms/sms_query_signature.php
vendored
Normal file
28
vendor/qiniu/php-sdk/examples/sms/sms_query_signature.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 列出签名
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5889/sms-api-query-signature
|
||||
|
||||
// 审核状态, 取值范围为: "passed"(通过), "rejected"(未通过), "reviewing"(审核中)
|
||||
$audit_status = 'passed';
|
||||
$page = 1; // 页码,默认为 1
|
||||
$page_size = 30; // 分页大小,默认为 20
|
||||
|
||||
list($ret, $err) = $client->querySignature($audit_status, $page, $page_size);
|
||||
echo "\n====> query signature result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/sms/sms_query_single_signature.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/sms/sms_query_single_signature.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 查询单个签名
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5970/query-a-single-signature
|
||||
|
||||
// 签名 ID
|
||||
$signature_id = 'xxxxxx';
|
||||
|
||||
list($ret, $err) = $client->checkSingleSignature($signature_id);
|
||||
echo "\n====> query single signature result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
26
vendor/qiniu/php-sdk/examples/sms/sms_query_single_template.php
vendored
Normal file
26
vendor/qiniu/php-sdk/examples/sms/sms_query_single_template.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 查询单个模板
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5969/query-a-single-template
|
||||
|
||||
// 模板 ID
|
||||
$template_id = 'xxxxxx';
|
||||
|
||||
list($ret, $err) = $client->querySingleTemplate($template_id);
|
||||
echo "\n====> query single template result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
28
vendor/qiniu/php-sdk/examples/sms/sms_query_template.php
vendored
Normal file
28
vendor/qiniu/php-sdk/examples/sms/sms_query_template.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 列出摸板
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5894/sms-api-query-template
|
||||
|
||||
// 审核状态, 取值范围为: passed (通过), rejected (未通过), reviewing (审核中)
|
||||
$audit_status = 'rejected';
|
||||
$page = 1; // 页码,默认为 1
|
||||
$page_size = 30; // 分页大小,默认为 20
|
||||
|
||||
list($ret, $err) = $client->queryTemplate($audit_status, $page, $page_size);
|
||||
echo "\n====> query template result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
32
vendor/qiniu/php-sdk/examples/sms/sms_send_message.php
vendored
Normal file
32
vendor/qiniu/php-sdk/examples/sms/sms_send_message.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Sms\Sms;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$client = new Sms($auth);
|
||||
|
||||
// 发送短信
|
||||
// 参考文档:https://developer.qiniu.com/sms/api/5897/sms-api-send-message
|
||||
|
||||
// 模板 ID
|
||||
$template_id = 'xxxxxx';
|
||||
|
||||
// 接收短信的手机号码
|
||||
$mobiles = array("15012345678", "15012345679");
|
||||
|
||||
// 自定义模板变量
|
||||
$code = array('code' => 'xxxx');
|
||||
|
||||
list($ret, $err) = $client->sendMessage($template_id, $mobiles, $code);
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
echo "\n====> Send Message Successfully: \n";
|
||||
var_dump($ret);
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/update_bucketEvent.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/update_bucketEvent.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 更新 bucket 事件通知规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||
|
||||
$bucket = 'xxxx';
|
||||
$name = 'demo';
|
||||
$prefix = 'test';
|
||||
$suffix = 'mp4';
|
||||
$event = array("move","copy");
|
||||
$callbackURL = 'https://www.qiniu.com';
|
||||
|
||||
list($ret, $err) = $bucketManager->updateBucketEvent($bucket, $name, $prefix, $suffix, $event, $callbackURL);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
36
vendor/qiniu/php-sdk/examples/update_bucketLifecycleRule.php
vendored
Normal file
36
vendor/qiniu/php-sdk/examples/update_bucketLifecycleRule.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Config;
|
||||
use Qiniu\Storage\BucketManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$config = new Config();
|
||||
$bucketManager = new BucketManager($auth, $config);
|
||||
|
||||
// 存储空间 - 更新生命周期规则
|
||||
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||
|
||||
$bucket = 'xxxx';
|
||||
$name = 'demo';
|
||||
$prefix = 'test';
|
||||
$delete_after_days = 90;
|
||||
$to_line_after_days =80;
|
||||
|
||||
list($ret, $err) = $bucketManager->updateBucketLifecycleRule(
|
||||
$bucket,
|
||||
$name,
|
||||
$prefix,
|
||||
$delete_after_days,
|
||||
$to_line_after_days
|
||||
);
|
||||
if ($err != null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
31
vendor/qiniu/php-sdk/examples/upload_and_callback.php
vendored
Normal file
31
vendor/qiniu/php-sdk/examples/upload_and_callback.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 上传完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
// 上传策略参数:https://developer.qiniu.com/kodo/manual/1206/put-policy
|
||||
|
||||
$policy = array(
|
||||
'callbackUrl' => 'http://your.domain.com/upload_verify_callback.php',
|
||||
'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
|
||||
);
|
||||
$uptoken = $auth->uploadToken($bucket, null, 3600, $policy);
|
||||
|
||||
// 上传文件的本地路径
|
||||
$filePath = './php-logo.png';
|
||||
|
||||
$uploadMgr = new UploadManager();
|
||||
list($ret, $err) = $uploadMgr->putFile($uptoken, null, $filePath);
|
||||
echo "\n====> putFile result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
49
vendor/qiniu/php-sdk/examples/upload_and_pfop.php
vendored
Normal file
49
vendor/qiniu/php-sdk/examples/upload_and_pfop.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 使用上传策略实现上传文件后,自动对该文件进行转码处理,并持久化生成一个新的文件存储到空间中
|
||||
|
||||
// 上传到七牛后保存的文件名
|
||||
$key = 'php-logo.png';
|
||||
|
||||
// 要上传文件的本地路径
|
||||
$filePath = './php-logo.png';
|
||||
|
||||
$uploadMgr = new UploadManager();
|
||||
|
||||
// 视频处理完毕后保存到空间中的名称
|
||||
$saveasKey = 'php-logo-rotate.png';
|
||||
|
||||
// 处理参数
|
||||
$pfop = "imageMogr2/rotate/90|saveas/" . \Qiniu\base64_urlSafeEncode("$bucket:$saveasKey");
|
||||
|
||||
// 转码完成后通知到你的业务服务器(需要可以公网访问,并能够相应 200 OK)
|
||||
$notifyUrl = 'http://notify.fake.com';
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
// 上传策略参数:https://developer.qiniu.com/kodo/manual/1206/put-policy
|
||||
$policy = array(
|
||||
'persistentOps' => $pfop,
|
||||
'persistentNotifyUrl' => $notifyUrl,
|
||||
'persistentPipeline' => $pipeline
|
||||
);
|
||||
$token = $auth->uploadToken($bucket, null, 3600, $policy);
|
||||
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
|
||||
echo "\n====> putFile result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
19
vendor/qiniu/php-sdk/examples/upload_mgr_init.php
vendored
Normal file
19
vendor/qiniu/php-sdk/examples/upload_mgr_init.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
// 存储空间名称
|
||||
$bucket = 'Bucket_Name';
|
||||
|
||||
// 生成上传 Token
|
||||
$token = $auth->uploadToken($bucket);
|
||||
|
||||
// 构建 UploadManager 对象
|
||||
$uploadMgr = new UploadManager();
|
||||
89
vendor/qiniu/php-sdk/examples/upload_multi_demos.php
vendored
Normal file
89
vendor/qiniu/php-sdk/examples/upload_multi_demos.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
|
||||
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||
$bucket = getenv('QINIU_TEST_BUCKET');
|
||||
|
||||
// 用户默认没有私有队列,需要在这里创建然后填写 https://portal.qiniu.com/dora/media-gate/pipeline
|
||||
$pipeline = 'sdktest';
|
||||
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$token = $auth->uploadToken($bucket);
|
||||
$uploadMgr = new UploadManager();
|
||||
|
||||
//---------------------------------------- upload demo1 ----------------------------------------
|
||||
// 上传字符串到七牛
|
||||
|
||||
list($ret, $err) = $uploadMgr->put($token, null, 'content string');
|
||||
echo "\n====> put result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------- upload demo2 ----------------------------------------
|
||||
// 上传文件到七牛
|
||||
|
||||
$filePath = './php-logo.png';
|
||||
$key = 'php-logo.png';
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
|
||||
echo "\n====> putFile result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------- upload demo3 ----------------------------------------
|
||||
// 上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器.
|
||||
// 可参考文档: https://developer.qiniu.com/kodo/manual/1206/put-policy
|
||||
|
||||
$policy = array(
|
||||
'callbackUrl' => 'http://172.30.251.210/upload_verify_callback.php',
|
||||
'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
|
||||
// 'callbackBodyType' => 'application/json',
|
||||
// 'callbackBody' => '{"filename":$(fname), "filesize": $(fsize)}' //设置application/json格式回调
|
||||
);
|
||||
$token = $auth->uploadToken($bucket, null, 3600, $policy);
|
||||
|
||||
|
||||
list($ret, $err) = $uploadMgr->putFile($token, null, $key);
|
||||
echo "\n====> putFile result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------- upload demo4 ----------------------------------------
|
||||
// 上传视频,上传完成后进行 m3u8 的转码, 并给视频打水印
|
||||
|
||||
$wmImg = Qiniu\base64_urlSafeEncode('http://devtools.qiniudn.com/qiniu.png');
|
||||
$pfop = "avthumb/m3u8/wmImage/$wmImg";
|
||||
|
||||
// 转码完成后回调到业务服务器。(公网可以访问,并相应 200 OK)
|
||||
$notifyUrl = 'http://notify.fake.com';
|
||||
|
||||
$policy = array(
|
||||
'persistentOps' => $pfop,
|
||||
'persistentNotifyUrl' => $notifyUrl,
|
||||
'persistentPipeline' => $pipeline
|
||||
);
|
||||
$token = $auth->uploadToken($bucket, null, 3600, $policy);
|
||||
print($token);
|
||||
list($ret, $err) = $uploadMgr->putFile($token, null, $key);
|
||||
echo "\n====> putFile result: \n";
|
||||
if ($err !== null) {
|
||||
var_dump($err);
|
||||
} else {
|
||||
var_dump($ret);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user