苹果登录 Sign In with Apple

 0, 'msg' => '', 'info' =>[]];
        $type = $_POST['type'];
        $clientUser = $_POST['openid'];
        $nickname = $_POST['nickname'];
        $avatar = $_POST['avatar'];

        //苹果授权登陆 identityToken 的验证
        if($type == 'apple'){
            //$identityToken = 'eyJraWQiOiJBSURPUEsxIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLmt1aW5pdS5rbiIsImV4cCI6MTU3OTUwODAzOSwiaWF0IjoxNTc5NTA3NDM5LCJzdWIiOiIwMDE5MDguYTJlYmM4NDA4YWRiNDNkZmIyYTdiMzJjN2ZkNTA4OTkuMTAxMCIsImNfaGFzaCI6ImxpbDg0ZEw0SHpjVE9VSkt4SHlXdUEiLCJlbWFpbCI6IjE1NTY5NjMwNzBAcXEuY29tIiwiZW1haWxfdmVyaWZpZWQiOiJ0cnVlIiwiYXV0aF90aW1lIjoxNTc5NTA3NDM5fQ.bTFCjMAT3dr6fARIlxg4W0zLgpBDds0LWSZnnPHGMe-YDN8sEZH-aNHjidJTO7GbmNtscGLhsRYM-qGv9j8XGFEYKh2UW23eLiS54CbPgNwobFmlWeSOeGm8qIcOXJ2P0xhy5untWQ2WBJXia4JpneDdDWksEQIBVtV_tC2zHPXlP5KUqMoEIyylLEZ87DPSRCa0AAOiqqbV9ookHrlMzEgYMGuurjVUm3p_0NgbOzauli9hy-j2-_0UwYQnaxY8ABGwcIBBiTgv_bUlnnqIDnE5D4nNIg0356B0-xgvjFrGPyOKh0H7hQQWpjHvbRxk1vnnNRjZ6CkLiUiPlp7Cog';
            //$clientUser = "001908.a2ebc8408adb43dfb2a7b32c7fd50899.10103";

            $identityToken = $_POST['identityToken'];
            if(!$identityToken){
                $return['code'] = 1001;
                $return['msg'] = 'identityToken not find';
                $return['msg_zn'] = '未获取到授权';
                return $return;
            }
            $appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);
            $isValid = $appleSignInPayload->verifyUser($clientUser);

            if(!$isValid){
                $return['code'] = 1001;
                $return['msg'] = 'identityToken error';
                $return['msg_zn'] = '授权失败';
                return $return;
            }
        }
        //去登陆
        $domain = new Domain_Login();
        $info = $domain->userLoginByThird($clientUser, $type, $nickname, $avatar);
        return $info;
    }
}

你可能感兴趣的:(苹果登录)