Skip to content

Commit e278f8c

Browse files
authored
Merge pull request #344 from qiniu/hbw
Update demo and add function
2 parents 0af6cb2 + 7cb933f commit e278f8c

32 files changed

+1193
-420
lines changed

docs/rtc/README.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

docs/rtc/example.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

docs/sms/example.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

examples/cdn_get_prefetch_list.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use Qiniu\Auth;
6+
use Qiniu\Cdn\CdnManager;
7+
8+
// 控制台获取密钥:https://portal.qiniu.com/user/key
9+
$accessKey = getenv('QINIU_ACCESS_KEY');
10+
$secretKey = getenv('QINIU_SECRET_KEY');
11+
12+
$auth = new Auth($accessKey, $secretKey);
13+
$cdnManager = new CdnManager($auth);
14+
15+
// 查询 CDN 预取记录
16+
// 参考文档:https://developer.qiniu.com/fusion/api/1227/file-prefetching#4
17+
18+
$requestId = null; // 指定要查询记录所在的刷新请求id
19+
$urls = null; // 要查询的url列表
20+
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
21+
$pageNo = 0; // 要求返回的页号,默认为0
22+
$pageSize = 100; // 要求返回的页长度,默认为100
23+
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
24+
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
25+
26+
list($ret, $err) = $cdnManager->getCdnPrefetchList(
27+
$requestId,
28+
$urls,
29+
$state,
30+
$pageNo,
31+
$pageSize,
32+
$startTime,
33+
$endTime
34+
);
35+
echo "\n====> query prefetch list: \n";
36+
if ($err !== null) {
37+
var_dump($err);
38+
} else {
39+
var_dump($ret);
40+
}

examples/cdn_get_refresh_list.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use Qiniu\Auth;
6+
use Qiniu\Cdn\CdnManager;
7+
8+
// 控制台获取密钥:https://portal.qiniu.com/user/key
9+
$accessKey = getenv('QINIU_ACCESS_KEY');
10+
$secretKey = getenv('QINIU_SECRET_KEY');
11+
12+
$auth = new Auth($accessKey, $secretKey);
13+
$cdnManager = new CdnManager($auth);
14+
15+
// 查询 CDN 刷新记录
16+
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh#4
17+
18+
$requestId = 'xxxxxx'; // 指定要查询记录所在的刷新请求id
19+
$isDir = 'no'; // 指定是否查询目录,取值为yes/no,默认不填则为两种类型记录都查询
20+
$urls = array(); // 要查询的url列表,每个url可以是文件url,也可以是目录url
21+
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
22+
$pageNo = 0; // 要求返回的页号,默认为0
23+
$pageSize = 100; // 要求返回的页长度,默认为100
24+
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
25+
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
26+
27+
list($ret, $err) = $cdnManager->getCdnRefreshList(
28+
$requestId,
29+
$isDir,
30+
$urls,
31+
$state,
32+
$pageNo,
33+
$pageSize,
34+
$startTime,
35+
$endTime
36+
);
37+
echo "\n====> query refresh list: \n";
38+
if ($err !== null) {
39+
var_dump($err);
40+
} else {
41+
var_dump($ret);
42+
}

examples/rtc/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Rtc Streaming Cloud Server-Side Library For PHP
2+
3+
## Features
4+
5+
- RoomToken 签发
6+
- [x] 生成 RoomToken: client->appToken()
7+
8+
- App 管理
9+
- [x] 创建应用: client->createApp()
10+
- [x] 获取应用配置信息: client->getApp()
11+
- [x] 更新应用配置信息: client->updateApp()
12+
- [x] 删除应用: client->deleteApp()
13+
14+
- 房间管理
15+
- [x] 列举房间下的所有用户: client->listUser()
16+
- [x] 指定一个用户踢出房间: client->kickUser()
17+
- [x] 停止一个房间的合流转推: client->stopMerge()
18+
- [x] 获取当前所有活跃的房间: client->listActiveRooms()
19+
20+
## Demo
21+
- RoomToken 签发
22+
- [生成 RoomToken](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_create_roomToken.php)
23+
24+
- App 管理
25+
- [创建应用](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_createApp.php)
26+
- [获取应用配置信息](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_getApp.php)
27+
- [更新应用配置信息](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_updateApp.php)
28+
- [删除应用](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_deleteApp.php)
29+
30+
- 房间管理
31+
- [列举房间下的所有用户](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_listUser.php)
32+
- [指定一个用户踢出房间](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_kickUser.php)
33+
- [停止一个房间的合流转推](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_stopMerge.php)
34+
- [获取当前所有活跃的房间](https://github.com/qiniu/php-sdk/tree/master/examples/rtc/rtc_rooms_listActiveRooms.php)

examples/rtc/rtc_createApp.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
require_once __DIR__ . '/../../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Rtc\AppClient;
6+
7+
// 控制台获取密钥:https://portal.qiniu.com/user/key
8+
$accessKey = getenv('QINIU_ACCESS_KEY');
9+
$secretKey = getenv('QINIU_SECRET_KEY');
10+
11+
$auth = new Auth($accessKey, $secretKey);
12+
$client = new AppClient($auth);
13+
14+
// 绑定的直播hub,使用此hub的资源进行推流等业务功能,hub与app必须属于同一个七牛账户
15+
$hub = 'rtchub';
16+
17+
// app 的名称,注意:Title 不是唯一标识,重复 create 动作将生成多个 app
18+
$title = 'rtc';
19+
20+
// 连麦房间支持的最大在线人数
21+
$maxUsers = 20;
22+
23+
// 创建应用
24+
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#2_1
25+
26+
list($ret, $err) = $client->createApp($hub, $title, $maxUsers);
27+
if ($err !== null) {
28+
var_dump($err);
29+
} else {
30+
echo "\n====> Create Successfully: \n";
31+
var_dump($ret);
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
require_once __DIR__ . '/../../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Rtc\AppClient;
6+
7+
// 控制台获取密钥:https://portal.qiniu.com/user/key
8+
$accessKey = getenv('QINIU_ACCESS_KEY');
9+
$secretKey = getenv('QINIU_SECRET_KEY');
10+
11+
$auth = new Auth($accessKey, $secretKey);
12+
$client = new AppClient($auth);
13+
14+
// app 的唯一标识,创建的时候由系统生成
15+
$appId = 'xxxx';
16+
17+
// 房间名称,需满足规格 ^[a-zA-Z0-9_-]{3,64}$
18+
$roomName = 'room01';
19+
20+
// 请求加入房间的用户 ID,需满足规格 ^[a-zA-Z0-9_-]{3,50}$
21+
$userId = '001';
22+
23+
// 鉴权的有效时间,传入以秒为单位的64位 Unix 绝对时间,token 将在该时间后失效
24+
$expireAt = time()+3600;
25+
26+
// "admin"或"user",默认为"user" 。当权限角色为"admin"时,拥有将其他用户移除出房间等特权
27+
$permission = 'admin';
28+
29+
// 生成加入房间的令牌 RoomToken
30+
// 参考文档:https://doc.qnsdk.com/rtn/docs/server_overview#1
31+
32+
$RoomToken = $client->appToken($appId, $roomName, $userId, $expireAt, $permission);
33+
echo "\n====> Create RoomToken Successfully: \n";
34+
var_dump($RoomToken);

0 commit comments

Comments
 (0)