sdkAppId = config('tencent.trtc.app_id'); $this->sdkSecretKey = config('tencent.trtc.secret_key'); } // 签名 public function genUserSign($identifier, $expire = 86400 * 180): string { try { $api = new TLSSigAPIv2($this->sdkAppId, $this->sdkSecretKey); return $api->genUserSig($identifier, $expire); } catch (\Exception $e) { echo $e; } } /** * userbuf签名. */ public function genSigWithUserBuf($identifier, $expire, $userbuf): string { try { $api = new TLSSigAPIv2($this->sdkAppId, $this->sdkSecretKey); return $api->genPrivateMapKeyWithStringRoomID($identifier, $expire,'', $userbuf); } catch (\Exception $e) { echo $e; } } public function verifySigWithUserBuf($sig, $identifier, $init_time, $expire_time, $userbuf, $error_msg) { try { $api = new TLSSigAPIv2($this->sdkAppId, $this->sdkSecretKey); return $api->verifySigWithUserBuf($sig, $identifier, $init_time, $expire_time, $userbuf, $error_msg); } catch (\Exception $e) { echo $e; } } /** * 批量用户生成签名. * * @return array */ public function genUserSigns($userIds, $expire) { $retData = []; foreach ($userIds as $id) { $retData[$id] = $this->genUserSign($id, $expire); } return $retData; } }