Index.php 1.8 KB

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