1.0
This commit is contained in:
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)新建。
|
||||
|
||||
42
vendor/qiniu/php-sdk/examples/bucket_lifecycleRule.php
vendored
Normal file
42
vendor/qiniu/php-sdk/examples/bucket_lifecycleRule.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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; // 用户新创建的文件将在该设定的时间之后自动转为低频存储
|
||||
$to_archive_ir_after_days = 71; // 用户新创建的文件将在该设定的时间之后自动转为归档直读存储
|
||||
$to_archive_after_days = 72; // 用户新创建的文件将在该设定的时间之后自动转为归档存储
|
||||
$to_deep_archive_after_days = 74; // 用户新创建的文件将在该设定的时间之后自动转为深度归档存储
|
||||
|
||||
list($ret, $err) = $bucketManager->bucketLifecycleRule(
|
||||
$bucket,
|
||||
$name,
|
||||
$prefix,
|
||||
$delete_after_days,
|
||||
$to_line_after_days,
|
||||
$to_archive_after_days,
|
||||
$to_deep_archive_after_days,
|
||||
$to_archive_ir_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);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user