Index.php 1.4 KB

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