Index.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. var_dump(input());
  19. var_dump(Session::get('wxId'));
  20. die();
  21. $data = CommonService::getSetData($channelId);
  22. if (empty(Session::get('wxId'))){
  23. Session::set('visitorId','');
  24. header("Location:".CommonService::getAuthUrl($channelId));
  25. die();
  26. }
  27. $visitorId = Session::get($visitorId);
  28. if(empty($visitorId)){
  29. Session::set('visitorId', $visitorId);
  30. }
  31. //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
  32. $key = md5($visitorId.$data['channel_auth_code']);
  33. if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
  34. $returnUrl = $notifyUrl."&key=".$key."&expire=3600";
  35. }else{
  36. $returnUrl = $notifyUrl."?key=".$key."&expire=3600";
  37. }
  38. header("Location:".$returnUrl);//跳转到直播观看页
  39. // redirect($returnUrl);
  40. }
  41. }