example.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once("../../autoload.php");
  3. use \Qiniu\Auth;
  4. $ak = 'gwd_gV4gPKZZsmEOvAuNU1AcumicmuHooTfu64q5';
  5. $sk = 'xxxx';
  6. $auth = new Auth($ak, $sk);
  7. $client = new Qiniu\Rtc\AppClient($auth);
  8. $hub = 'lfxlive';
  9. $title = 'lfxl';
  10. try {
  11. //创建app
  12. $resp = $client->createApp($hub, $title, $maxUsers);
  13. print_r($resp);
  14. // 获取app状态
  15. $resp = $client->getApp('dgdl5ge8y');
  16. print_r($resp);
  17. //修改app状态
  18. $mergePublishRtmp = null;
  19. $mergePublishRtmp['enable'] = true;
  20. $resp = $client->updateApp('dgdl5ge8y', $hub, $title, $maxUsers, $mergePublishRtmp);
  21. print_r($resp);
  22. //删除app
  23. $resp = $client->deleteApp('dgdl5ge8y');
  24. print_r($resp);
  25. //获取房间连麦的成员
  26. $resp=$client->listUser("dgbfvvzid", 'lfxl');
  27. print_r($resp);
  28. //剔除房间的连麦成员
  29. $resp=$client->kickUser("dgbfvvzid", 'lfx', "qiniu-f6e07b78-4dc8-45fb-a701-a9e158abb8e6");
  30. print_r($resp);
  31. // 列举房间
  32. $resp=$client->listActiveRooms("dgbfvvzid", 'lfx', null, null);
  33. print_r($resp);
  34. //鉴权的有效时间: 1个小时.
  35. $resp = $client->appToken("dgd4vecde", "lfxl", '1111', (time()+3600), 'user');
  36. print_r($resp);
  37. } catch (\Exception $e) {
  38. echo "Error:", $e, "\n";
  39. }