Skip to content

Commit

Permalink
fix the code error
Browse files Browse the repository at this point in the history
  • Loading branch information
jemygraw committed May 9, 2018
1 parent d2ed225 commit cd02fa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/rtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [x] 创建房间: client->createApp()
- [x] 查看房间: client->getApp()
- [x] 删除房间: client->deleteApp()
- [x] 生成房间token: client->AppToken()
- [x] 生成房间token: client->appToken()



Expand All @@ -32,7 +32,7 @@
$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5";
$sk = "xxxx";
$auth = new Auth($ak, $sk);
$client = new QiniuRtc\AppClient($auth);
$client = new Qiniu\Rtc\AppClient($auth);
$resp=$client->createApp("901","testApp");
print_r($resp);
```
Expand All @@ -43,7 +43,7 @@ print_r($resp);
$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5";
$sk = "xxxx";
$auth = new Auth($ak, $sk);
$client = new QiniuRtc\AppClient($auth);
$client = new Qiniu\Rtc\AppClient($auth);
$resp=$client->getApp("deq02uhb6");
print_r($resp);
```
Expand All @@ -54,7 +54,7 @@ print_r($resp);
$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5";
$sk = "xxxx";
$auth = new Auth($ak, $sk);
$client = new QiniuRtc\AppClient($auth);
$client = new Qiniu\Rtc\AppClient($auth);
$resp=$client->deleteApp("deq02uhb6");
print_r($resp);
```
Expand All @@ -65,7 +65,7 @@ print_r($resp);
$ak = "gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5";
$sk = "xxxx";
$auth = new Auth($ak, $sk);
$client = new QiniuRtc\AppClient($auth);
$client = new Qiniu\Rtc\AppClient($auth);
$resp=$client->appToken("deq02uhb6", "lfx", '1111', (time()+3600), 'user');
print_r($resp);
```
16 changes: 8 additions & 8 deletions src/Qiniu/Rtc/AppClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function listActiveRooms($appId, $prefix = null, $offset = null, $limit =
if (isset($limit)) {
$query['limit'] = $limit;
}
if ($query != null) {
if (isset($query) && !empty($query)) {
$query = '?' . http_build_query($query);
$url = sprintf("%s/%s/rooms%s", $this->baseURL, $appId, $query);
} else {
Expand Down Expand Up @@ -170,7 +170,7 @@ public function appToken($appId, $roomName, $userId, $expireAt, $permission)

private function get($url, $cType = null)
{
$rtcToken = $this->auth->authorizationV2($url, "GET", $body, $cType);
$rtcToken = $this->auth->authorizationV2($url, "GET", null, $cType);
$rtcToken['Content-Type'] = $cType;
$ret = Client::get($url, $rtcToken);
if (!$ret->ok()) {
Expand All @@ -179,21 +179,21 @@ private function get($url, $cType = null)
return array($ret->json(), null);
}

private function delete($url, $cType = 'application/json')
private function delete($url, $contentType = 'application/json')
{
$rtcToken = $this->auth->authorizationV2($url, "DELETE", $body, $cType);
$rtcToken['Content-Type'] = $cType;
$rtcToken = $this->auth->authorizationV2($url, "DELETE", null, $contentType);
$rtcToken['Content-Type'] = $contentType;
$ret = Client::delete($url, $rtcToken);
if (!$ret->ok()) {
return array(null, new Error($url, $ret));
}
return array($ret->json(), null);
}

private function post($url, $body, $cType = 'application/json')
private function post($url, $body, $contentType = 'application/json')
{
$rtcToken = $this->auth->authorizationV2($url, "POST", $body, $cType);
$rtcToken['Content-Type'] = $cType;
$rtcToken = $this->auth->authorizationV2($url, "POST", $body, $contentType);
$rtcToken['Content-Type'] = $contentType;
$ret = Client::post($url, $body, $rtcToken);
if (!$ret->ok()) {
return array(null, new Error($url, $ret));
Expand Down

0 comments on commit cd02fa6

Please sign in to comment.