Wallogit.com
2017 © Pedro Peláez
GAuthify PHP Client Library
Direct link to library., (*1)
This is the PHP API Client for GAuthify. The GAuthify REST api helps websites quickly add multi-factor authentication through Google Authenticator, SMS, and Email. This package is a simple wrapper around that api., (*2)
It has been forked by Joshua Eichorn @Pagely(https://pagely.com) to be namespaced and installable with composer, (*3)
Install using composer, (*4)
composer require jeichorn/g-authify-php
Include vendor/autoload.php, and use the class, (*5)
include 'vendor/autoload.php'; use GAuthify\GAuthify;
To run a quick test to make sure everything works fine run:, (*6)
include 'vendor/autoload.php'; use GAuthify\GAuthify; $gauthify = new GAuthify(<api_key>); $gauthify->quick_test(<test_email>(optional), <test_number>(optional));
First get an API key by signing up for an account here., (*7)
First instantiate a GAuthify object:, (*8)
include 'vendor/autoload.php'; use GAuthify\GAuthify; $auth_instance = new GAuthify(<api_key>);
auth_instance->create_user(<unique_id>, <display_name>, <email> *optional, <sms_number> *optional, <voice_number> *optional)
The user hash returned will have parameters outlined on the GAuthify.com dashboard page. You can show the user the QR code to scan in their google authenticator applicatoin or you can link/iframe the instructions url., (*9)
auth_instance->update_user(<unique_id>, <email> *optional, <sms_number> *optional, <voice_number> *optional, <reset_key> *optional)
auth_instance->delete_user(<unique_id>)
auth_instance->get_all_users()
* Returns: List of user hashes, (*10)
auth_instance->get_user(<unique_id>)
auth_instance->get_user_by_token(<token>)
auth_instance->check_auth(<unique_id>, <auth_code>, safe_mode = False)
auth_instance->send_email(<unique_id>, <email> *optional)
auth_instance->send_sms(<unique_id>, <sms_number> *optional)
auth_instance->send_voice(<unique_id>, <voice_number> *optional)
Up to-date json formatted errors can be grabbed from the server using:, (*11)
auth_instance->api_errors()
They should rarely change and will be backward compatible., (*12)
The primary error class is GAuthifyError, it can be used as follows:, (*13)
use GAuthify\GAuthifyError;
try{
<code here>
}
catch (GAuthifyError $e){
print(e->msg) # The error message
print(e->http_status) # The http status code
print(e->error_code) # A error code listed in the GAuthfiy application
print(e->response_body) # The raw http response
}
The following errors extend GAuthifyError:, (*14)