Skip to content

Commit 9a429ea

Browse files
committed
Optimization code
1 parent ce3eada commit 9a429ea

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

rtc/example/example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
$resp=$client->listRooms("dgbfvvzid", 'lfx', null, null);
3636
print_r($resp);exit;
3737
//鉴权的有效时间: 1个小时.
38-
$resp = $client->appToken("dgbng7v36", "lfxl", '1111', (time()+3600), 'user');
38+
$resp = $client->appToken("dgd3fky76", "lfxl", '1111', (time()+3600), 'user');
3939
print_r($resp);exit;
4040
} catch (\Exception $e) {
4141
echo "Error:", $e, "\n";

src/Qiniu/Auth.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
final class Auth
77
{
8-
public $accessKey;
9-
public $secretKey;
8+
private $accessKey;
9+
private $secretKey;
1010

1111
public function __construct($accessKey, $secretKey)
1212
{
@@ -19,6 +19,11 @@ public function getAccessKey()
1919
return $this->accessKey;
2020
}
2121

22+
public function getSecretKey()
23+
{
24+
return $this->secretKey;
25+
}
26+
2227
public function sign($data)
2328
{
2429
$hmac = hash_hmac('sha1', $data, $this->secretKey, true);

src/Qiniu/Rtc/AppClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ public function appToken($appId, $roomName, $userId, $expireAt, $permission)
164164
$params['expireAt'] = $expireAt;
165165
$appAccessString = json_encode($params);
166166
$encodedappAccess = \Qiniu\base64_urlSafeEncode($appAccessString);
167-
$sign = hash_hmac('sha1', $encodedappAccess, $this->auth->secretKey, true);
167+
$sign = hash_hmac('sha1', $encodedappAccess, $this->auth->getSecretKey(), true);
168168
$encodedSign = \Qiniu\base64_urlSafeEncode($sign);
169-
return $this->auth->accessKey . ":" . $encodedSign . ":" . $encodedappAccess;
169+
return $this->auth->getAccessKey() . ":" . $encodedSign . ":" . $encodedappAccess;
170170
}
171171

172172
private function get($url, $cType = null)

0 commit comments

Comments
 (0)