Index.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2020/12/5 17:55
  5. */
  6. namespace app\index\controller;
  7. use app\common\service\CommonService;
  8. use app\index\exception\ApiException;
  9. use app\index\model\UserModel;
  10. use think\facade\Session;
  11. class Index {
  12. public function index() {
  13. $visitorId = input('visitorId');
  14. $notifyUrl = input('notify_url');
  15. $channelId = input('channelId');
  16. if (empty($channelId)){
  17. throw new ApiException('渠道id不为空');
  18. }
  19. $data = CommonService::getSetData($channelId);
  20. $info = (new UserModel())::where(['unionid' => Session::get('wxId'), 'channel_id' => $channelId])
  21. ->order(['id' => 'desc'])->find();
  22. if (empty(Session::get('wxId')) || empty($info)){
  23. $temp = CommonService::getAuthUrl($channelId);
  24. header("Location:".$temp);
  25. die();
  26. }
  27. $params = [
  28. 'id' => $info['channel_id'],
  29. 'userid' => $info['unionid'],
  30. 'name' => $info['name'],
  31. 'avatar' => $info['avatar'],
  32. 'key' => $info['key']
  33. ];
  34. header('Location:http://webcasting.bizconfstreaming.com/activity.php?a=userAssign&'.http_build_query($params));
  35. die();
  36. //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
  37. $key = md5($visitorId.$data['channel_auth_code']);
  38. if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
  39. $returnUrl = $notifyUrl."&key=".$key."&expire=1";
  40. }else{
  41. $returnUrl = $notifyUrl."?key=".$key."&expire=1";
  42. }
  43. header("Location:".$returnUrl);//跳转到直播观看页
  44. // redirect($returnUrl);
  45. }
  46. }