PHP code example of ecoiris / php-signin-apple

1. Go to this page and download the library: Download ecoiris/php-signin-apple library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ecoiris / php-signin-apple example snippets


use AppleSign\ASDecoder;
use Illuminate\Http\Request;

public function appLogin(Request $request) 
{
    // 客户端集成苹果授权,授权后可以获取到以下信息
    $userId = $request->input('userId');
    $identityToken = $request->input('identityToken');
    $email = $request->input('email');
    $fullName = $request->input('fullName');
    
    $appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);
    $isValid = $appleSignInPayload->verifyUser($userId);
    if ($isValid) {// 验证通过
        print_r('验证通过后的逻辑');
        return;
    }
    print_r('验证失败后的逻辑');
    return;
}
shell
composer