1. Go to this page and download the library: Download ghayma/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/ */
use Ghayma\Sdk\Exception\TwoFactorRequiredException;
use Ghayma\Sdk\Model\TwoFaEnrollmentRequired;
use Ghayma\Sdk\Model\TwoFaRequired;
try {
$session = $auth->exchangeCode($code, $codeVerifier, $clientIp);
} catch (TwoFactorRequiredException $e) {
if ($e->result instanceof TwoFaRequired) {
$session = $auth->verify2fa($e->result->challengeToken, $totpCode, $clientIp);
} elseif ($e->result instanceof TwoFaEnrollmentRequired) {
$enrollment = $auth->enrollTotp($e->result->enrollToken); // render $enrollment->otpauthUri as a QR
$confirmation = $auth->confirmTotp($totpCode, $e->result->enrollToken); // ->session, ->recoveryCodes
}
}
use Ghayma\Sdk\Exception\RateLimitedException;
use Ghayma\Sdk\Exception\GhaymaException;
try {
$auth->login($email, $password, $clientIp);
} catch (RateLimitedException $e) {
// back off for $e->retryAfter seconds
} catch (GhaymaException $e) {
// $e->status, $e->errorCode, $e->getMessage()
}
$ghayma = new Ghayma('gsk_…', 'https://api.ghayma.tech', $psr18Client, $requestFactory, $streamFactory);
$auth = new GhaymaAuth('my-app', 'https://auth.ghayma.tech', 'ghs_…', $psr18Client, $requestFactory, $streamFactory);
use Ghayma\Sdk\Ghayma;
use Ghayma\Sdk\GhaymaAuth;
public function register(): void
{
$this->app->singleton(Ghayma::class, fn () => new Ghayma(config('services.ghayma.api_key')));
$this->app->singleton(GhaymaAuth::class, fn () => new GhaymaAuth(
appSlug: config('services.ghayma.app_slug'),
serverKey: config('services.ghayma.server_key'),
));
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.