PHP code example of bitanswer / php-sdk

1. Go to this page and download the library: Download bitanswer/php-sdk 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/ */

    

bitanswer / php-sdk example snippets


use Bit\Auth\Authentication;

$authentication = new Authentication(
    $app_id, // 用来唯一标识App
    $app_secret, // app密码
    $app_host, // 用户池域名
    $protocol, // 认证协议,目前仅支持oidc
    $redirect_uri = null); // 回调地址

// 获取登录地址
$authentication->getAuthorizeUrl();
// 获取accessToken
$authentication->getAccessTokenByCode($code);
// 获取登出地址
$authentication->getLogoutUrl();

try {
    $authentication = new Authentication(...);
    $authentication->getAuthorizeUrl();
} catch (\Exception $e) {
    print_r($e);
}

shell
composer