Index.php 1.1 KB

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