TencentImMessage.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Services;
  3. use App\Models\User;
  4. use App\Traits\TencentIm;
  5. use PHPUnit\Util\Exception;
  6. class TencentImMessage
  7. {
  8. use TencentIm;
  9. //查询单聊消息
  10. public function getroammsg($from,$to){
  11. if(empty($from)){
  12. throw new Exception("参数错误");
  13. }
  14. if(empty($to)){
  15. throw new Exception("参数错误");
  16. }
  17. $from = User::query()->find($from,['tencent_im_user_id']);
  18. $to = User::query()->find($to,['tencent_im_user_id']);
  19. $this->restApiName = "v4/openim/admin_getroammsg";
  20. $baseApiHost = $this->getTencentImRestApiBaseHost();
  21. $params = [
  22. 'From_Account' => $from->tencent_im_user_id,
  23. 'To_Account' => $to->tencent_im_user_id,
  24. 'MaxCnt' => 999,
  25. 'MinTime' => 1625068800,
  26. 'MaxTime' => 1751299200,
  27. ];
  28. $apiResult = $this->requestApi($baseApiHost, $params);
  29. self::verifyApiResult($apiResult);
  30. return $apiResult;
  31. }
  32. }