PHP code example of google / identity-toolkit-php-client
1. Go to this page and download the library: Download google/identity-toolkit-php-client 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/ */
google / identity-toolkit-php-client example snippets
$gitkitClient = Gitkit_Client::createFromFile("gitkit-server-config.json");
// ---- upload account -----
$hashKey = "\x01\x02\x03";
$gitkitClient->uploadUsers('HMAC_SHA1', $hashKey, createNewUsers($hashKey));
// --- verify gitkit token ----
$user = $gitkitClient->validateToken("eyJhb...");
// ---- get account info by user identifier ----
$user = $gitkitClient->getUserById("1234");
// ---- get a url to send to user's email address to verify ownership -----
$verificationLink = $gitkitClient->getEmailVerificationLink("[email protected]");
// ---- download account ----
$iterator = $gitkitClient->getAllUsers(3);
while ($iterator->valid()) {
$user = $iterator->current();
// $user is a Gitkit_Account object
$iterator->next();
}
// ---- delete account ----
$gitkitClient->deleteUser('1234');
function createNewUsers($hashKey) {
$allUsers = array();
$gitkitUser = new Gitkit_Account();
$gitkitUser->setEmail("[email protected]");
$gitkitUser->setUserId("1234");
$salt = "\05\06\07";
$password = '1111';
$gitkitUser->setSalt($salt);
$gitkitUser->setPasswordHash(hash_hmac('sha1', $password . $salt, $hashKey, true));
array_push($allUsers, $gitkitUser);
$gitkitUser = new Gitkit_Account();
$gitkitUser->setEmail('[email protected]');
$gitkitUser->setUserId('5678');
$salt = "\15\16\17";
$password = '5555';
$gitkitUser->setSalt($salt);
$gitkitUser->setPasswordHash(hash_hmac('sha1', $password . $salt, $hashKey, true));
array_push($allUsers, $gitkitUser);
return $allUsers;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.