User.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2020/12/5 17:15
  5. */
  6. namespace app\api\controller;
  7. use app\api\BaseController;
  8. use app\common\service\CommonService;
  9. class User extends BaseController {
  10. public function login() {
  11. $params = [
  12. 'id' => CommonService::getChannelId(),
  13. 'userid' => input('unionid'),
  14. 'name' => input('nickName'),
  15. 'avatar' => input('avatar'),
  16. 'key' => md5(input('userid').CommonService::getAuthKey())
  17. ];
  18. session('unionid', input('unionid'));
  19. header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
  20. }
  21. public function checkLogin() {
  22. $visitorId = input('visitorId');
  23. $notifyUrl = input('notify_url');
  24. if (empty(session('unionid'))){
  25. header("Location:".CommonService::getAuthUrl());
  26. die();
  27. }
  28. //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
  29. $key = md5($visitorId.CommonService::getAuthKey());
  30. if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
  31. $returnUrl = $notifyUrl."&key=".$key."&expire=3600";
  32. }else{
  33. $returnUrl = $notifyUrl."?key=".$key."&expire=3600";
  34. }
  35. header("Location:".$returnUrl.'&a='.session('unionid'));//跳转到直播观看页
  36. // redirect($returnUrl);
  37. }
  38. }