ThirdH5ChatFacadeRepository.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\Repositories\Eloquent;
  3. use App\Repositories\Eloquent\BaseRepository;
  4. use App\Repositories\Contracts\ThirdH5ChatInterface;
  5. /**
  6. *
  7. * @author lilin
  8. *
  9. */
  10. class ThirdH5ChatFacadeRepository extends BaseRepository implements ThirdH5ChatInterface
  11. {
  12. public function getChatUrl($uid, $nickname, $headUrl)
  13. {
  14. $this->setLog(self::TYPENAME.'getChatUrl step_1 开始', $this->startTime());
  15. $url = config('console.thirdH5Chat.url');
  16. $secret = config('console.thirdH5Chat.secret');
  17. $parameter = [
  18. 'appid' => config('console.thirdH5Chat.appid'),
  19. 'user_key' => urlencode($uid),
  20. 'nick_name' => $nickname,
  21. 'head_url' => urlencode($headUrl)
  22. ];
  23. $this->setLog(self::TYPENAME.'getChatUrl step_2 请求参数', $this->startTime, $parameter);
  24. //token算法是 appid+user_key+secret
  25. $str = $parameter['appid'].$uid.$secret;
  26. $parameter['token'] = md5($str);
  27. $this->setLog(self::TYPENAME.'getChatUrl step_3 加入token', $this->startTime, $parameter);
  28. $query = '';
  29. foreach ($parameter as $key => $value) {
  30. $query .= '&'.$key . '=' . $value;
  31. }
  32. return $this->response($url.$query);
  33. }
  34. }