The Ding PHP library provides convenient access to the Ding API from applications written in the PHP language.
composer require "ding/sdk"
Send an OTP code to a user's phone number.
declare(strict_types=1);
require 'vendor/autoload.php';
use Ding\DingSDK;
use Ding\DingSDK\Models\Shared;
$security = new Shared\Security();
$security->apiKey = 'YOUR_API_KEY';
$sdk = DingSDK\Ding::builder()->setSecurity($security)->build();
try {
$request = new Shared\CreateAuthenticationRequest(
customerUuid: 'c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phoneNumber: '+1234567890',
appRealm: '<value>',
appVersion: '<value>',
callbackUrl: 'https://thin-television.name',
correlationId: '<value>',
deviceId: '<value>',
deviceModel: '<value>',
deviceType: Shared\DeviceType::Android,
ip: '176.157.112.67',
isReturningUser: false,
osVersion: '<value>',
templateId: '<value>',
);
$response = $sdk->otp->createAuthentication($request);
if ($response->createAuthenticationResponse !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Check that a code entered by a user is valid.
declare(strict_types=1);
require 'vendor/autoload.php';
use Ding\DingSDK;
use Ding\DingSDK\Models\Shared;
$security = new Shared\Security();
$security->apiKey = 'YOUR_API_KEY';
$sdk = DingSDK\Ding::builder()->setSecurity($security)->build();
try {
$request = new Shared\CreateCheckRequest(
authenticationUuid: 'e0e7b0e9-739d-424b-922f-1c2cb48ab077',
checkCode: '123456',
customerUuid: '8f1196d5-806e-4b71-9b24-5f96ec052808',
);
$response = $sdk->otp->check($request);
if ($response->createCheckResponse !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Perform a retry if a user has not received the code.
declare(strict_types=1);
require 'vendor/autoload.php';
use Ding\DingSDK;
use Ding\DingSDK\Models\Shared;
$security = new Shared\Security();
$security->apiKey = 'YOUR_API_KEY';
$sdk = DingSDK\Ding::builder()->setSecurity($security)->build();
try {
$request = new Shared\RetryAuthenticationRequest(
authenticationUuid: 'a74ee547-564d-487a-91df-37fb25413a91',
customerUuid: '3c8b3a46-881e-4cdd-93a6-f7f238bf020a',
);
$response = $sdk->otp->retry($request);
if ($response->retryAuthenticationResponse !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
- check - Check a code
- createAuthentication - Send a code
- feedback - Send feedback
- retry - Perform a retry
- lookup - Perform a phone number lookup
composer require "ding-live/ding-php"
You can override the default server globally by passing a server index to the server_idx: int
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://api.ding.live/v1 |
None |
The default server can also be overridden globally by passing a URL to the server_url: str
optional parameter when initializing the SDK client instance. For example:
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!