コード例 #1
0
 /**
  * 管理员注册(内部接口)
  * @apiMethod post
  * @apiParam string mobile 手机号
  * @apiParam string password 密码
  * @apiParam string rePassword 密码确认
  * @return array
  * @throws Wk_Exception
  */
 public function submitAdminRegisterAction()
 {
     $mobile = Wk_Request::getRequestString("mobile", null, false);
     $password = Wk_Request::getRequestString("password", null, false);
     $rePassword = Wk_Request::getRequestString("rePassword", null, false);
     if ($password != $rePassword) {
         throw new Wk_Exception("管理员注册两次密码不一致,请重新输入", -1);
     }
     $userid = WkAdminUserService::getInstance()->submitAdminUserRegister($mobile, $password);
     return ['userid' => $userid];
 }
コード例 #2
0
ファイル: UserApiController.php プロジェクト: telander/waka
 /**
  * 微信登录
  * @return Wk_User
  * @throws Wk_Exception
  */
 public function submitWxLoginAction()
 {
     $openId = Wk_Request::getRequestString("openId", null, false);
     $user = WkUserService::getInstance()->submitLoginWithWechat($openId);
     if (session_status() == PHP_SESSION_ACTIVE) {
         $appParam = [];
         $appParam['token'] = $user->token;
         $_SESSION['appParam'] = $appParam;
     }
     return $user;
 }
コード例 #3
0
ファイル: SnsApiController.php プロジェクト: telander/waka
 /**
  * 通过跳转方式获得微信基本授权,可获得用户信息,但是会在微信里弹授权确认框
  * @apiMethod get|post
  * @apiParam string retUrl 微信回调URL
  * @apiParam string [state=userinfo] 获取的信息
  */
 public function getWxOAuth2Redirect_UserInfoAction()
 {
     $returl = Wk_Request::getRequestString("retUrl");
     // state可以传openId, 防止用户不通过授权,这样依然可以拿到用户的一些信息。
     $state = Wk_Request::getRequestString("state", "userinfo");
     $redirectUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . Wk::$config['wechat']['WX_AKEY'] . "&redirect_uri=" . urlencode($returl) . "&response_type=code&scope=snsapi_userinfo&state=" . $state . "#wechat_redirect";
     Wk_Request::redirect($redirectUrl);
 }