PHP SDK document is in docs.tfasoft.com
If you are using TFA as your authentication service in your PHP applications, you can use our library.
So, let's have a quick review of our steps.
You can install this as a composer package:
$ composer install tfasoft/sdk;
Usage:
<?php
// ...
require_once __DIR__ . '/vendor/autoload.php';
// ...
use TFASoft\TFA;
// ...
$tfa = new TFA("<access-token>"); // you can use $tfa->getAccessToken() to get the value you've set here
$result = $tfa->authUser('<user-token>');
// ...
The $result
will be an array with two status
and data
keys.
$result["status"]
will be the status code.
And go to the next part to see structure of $result["data"]
;
Also you can change the base URL of the API:
$tfa = new TFA("<access-token>", 'http://base-url/of/api/');
// ...
$tfa->getBaseUrl(); // http://base-url/of/api/
Here let's know about them in deep (possible results in $result['data']
).
{
"user": {
"_id": "document id",
"uid": "telegram user id",
"token": "one time token. Every time become null",
"createdAt": "when created",
"updatedAt": "last update",
"__v": 0
}
}
One is access token is wrong.
{
"message": "User authentication token is not valid"
}
Another is when user token is wrong.
{
"message": "Admin access token is not valid"
}
If you want to contribute or change the code:
- Clone the project
- Install dependencies by running
$ composer install
- Start changing!
To test your changes, you can create a .env
file in root directory of project:
TEST_ACCESS_TOKEN="<access-token>"
TEST_USER_TOKEN="<user-token>"
and then run $ composer test
.