PHP code example of authing-sdk / php-71

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

    

authing-sdk / php-71 example snippets


use Authing\Mgmt\ManagementClient;

$management = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
// 获取管理员权限
$management->requestToken();

use Authing\Mgmt\ManagementClient;

$management = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
// 获取管理员权限
$management->requestToken();
$users = $management->users()->paginate();

use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});

use Authing\Auth\AuthenticationClient;
use Authing\Types\LoginByEmailInput;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$user = $authentication->loginByEmail(new LoginByEmailInput("[email protected]", "123456"));

use Authing\Auth\AuthenticationClient;
use Authing\Types\LoginByEmailInput;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$authentication->loginByEmail(new LoginByEmailInput("[email protected]", "123456"));

$user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));

use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$authentication->setAccessToken("ACCESS_TOKEN");

use Authing\Auth\AuthenticationClient;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$authentication->setAccessToken("ACCESS_TOKEN");

$user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));

use Authing\Auth\AuthenticationClient;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$authentication->setAccessToken("ACCESS_TOKEN");

try {
    $user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));
} catch (Exception $e) {
    print_r($e);
}
shell
# latest stable
$ composer