Skip to content

Commit b2b6ac1

Browse files
committed
Optimization code
1 parent 455f39e commit b2b6ac1

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

rtc/example/example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), 'lib', 'Rtc_v3.php'));
44

55
$ak = 'gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5';
6-
$sk = 'xxxx';
6+
$sk = '9G4isTkVuj5ITPqH1ajhljJMTc2k4m-hZh5r5ZsK';
77

88
$mac = new Qiniu\Rtc\Mac($ak, $sk);
99
$client = new Qiniu\Rtc\AppClient($mac);
@@ -31,7 +31,7 @@
3131
$resp=$client->kickingPlayer("deqq25wl9", 'lfx', "qiniu-f6e07b78-4dc8-45fb-a701-a9e158abb8e6");
3232
print_r($resp);
3333
// 列举房间
34-
$resp=$client->listRooms("deqq25wl9", null, null, null);
34+
$resp=$client->listRooms("deqq25wl9", 'lfx', null, null);
3535
print_r($resp);
3636
//鉴权的有效时间: 1个小时.
3737
$resp = $client->appToken("desqva26d", "lfxl", '1111', (time()+3600), 'user');

rtc/lib/Qiniu/Rtc/AppClient.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,23 @@ public function kickingPlayer($appId, $roomName, $userId)
163163
* limit: int 类型,此次查询的最大长度。
164164
* GET /v3/apps/<AppID>/rooms?prefix=<RoomNamePrefix>&offset=<Offset>&limit=<Limit>
165165
*/
166-
public function listRooms($appId, $prefix, $offset, $limit)
166+
public function listRooms($appId, $prefix = null, $offset = null, $limit = null)
167167
{
168-
$url = sprintf("%s/%s/rooms", $this->_baseURL, $appId);
168+
if(isset($prefix)){
169+
$query['prefix'] = $prefix;
170+
}
171+
if(isset($offset)){
172+
$query['offset'] = $offset;
173+
}
174+
if(isset($limit)){
175+
$query['limit'] = $limit;
176+
}
177+
if ($query != null) {
178+
$query = '?' . http_build_query($query);
179+
$url = sprintf("%s/%s/rooms%s", $this->_baseURL, $appId, $query);
180+
} else {
181+
$url = sprintf("%s/%s/rooms", $this->_baseURL, $appId);
182+
}
169183
try {
170184
$ret = $this->_transport->send(HttpRequest::GET, $url);
171185
} catch (\Exception $e) {

rtc/lib/Qiniu/Rtc/HttpRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public static function send($httpMethod, $url, $body = null, $headers = array())
129129
foreach ($finalHeaders as $key => $val) {
130130
$annexHeaders[] = self::getHeader($key, $val);
131131
}
132-
$lowerCaseFinalHeaders = array_change_key_case($finalHeaders);
133132
$ch = curl_init();
134133
if ($httpMethod != self::GET) {
135134
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);

0 commit comments

Comments
 (0)