Index.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 think\facade\Session;
  10. class Index {
  11. public function index() {
  12. $visitorId = input('visitorId');
  13. $notifyUrl = input('notify_url');
  14. $channelId = input('channelId');
  15. if (empty($channelId)){
  16. throw new ApiException('渠道id不为空');
  17. }
  18. $data = CommonService::getSetData($channelId);
  19. if (empty(Session::get('wxId'))){
  20. Session::set('visitorId','');
  21. header("Location:".CommonService::getAuthUrl($channelId));
  22. die();
  23. }
  24. Session::get($visitorId);
  25. Session::set('visitorId', $visitorId);
  26. //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
  27. $key = md5($visitorId.$data['channel_auth_code']);
  28. if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
  29. $returnUrl = $notifyUrl."&key=".$key."&expire=3600";
  30. }else{
  31. $returnUrl = $notifyUrl."?key=".$key."&expire=3600";
  32. }
  33. header("Location:".$returnUrl);//跳转到直播观看页
  34. // redirect($returnUrl);
  35. }
  36. }