Add Two Step Verification (TSV) to your website with Teleoh™

As part of our continuous effort to add new tools to Teleoh™ we are happy to bring you the first of many “Tool” API’s. The Two Step Verification API (or “TSV” for short) allows you to quickly add TSV (also know as Two Step Authentication) to your web site or login system. Our TSV API can handle verification via SMS or phone call.

Whether you need TSV for sign in security, billing & payment verification, or any other need, Teleoh™ makes it easier than ever. Send users your choice of a phone call or text message to verify their identity.

Documentation
https://docs.hawkinsegroup.com/teleoh/#TSV-Create

—-

Download this entire package : tsv_phone.zip
NOTE: After downloading first change the static variables (step 2 below) before uploading to your server and/or web host.

—-

Tutorial

A step by step tutorial to help you get the TSV API from Teleoh™ working with PHP (phone call).

Step 1 : Include the Teleoh PHP Class
1
require_once 'class.teleoh.php';

Get the Teleoh™ class on GitHub here.

Step 2 : Set Static Variables

These are used by the TSV API, specifically “company_name” will be announced by Watson. For example “This is a two step verification call from [Company Name], please enter the verification code shown on your screen”.

1
2
3
4
5
6
//Set your variables below
    $company_name = 'Hawkins';
    $from_phone_number = '19723625216'; //Must be a number you own from your Teleoh™ account.
    $redirect_url = 'https://developer.teleoh.com'; //Where to take the user after successful verification.
    $API_USER_ID = ''; //Found here: https://developer.teleoh.com/show/credentials
    $API_KEY = ''; //Found here: https://developer.teleoh.com/show/credentials
Step 3 : Initialize the Teleoh API and PHP session.
1
2
session_start();
$teleoh_api = new teleohapi($API_USER_ID,$API_KEY,$HEG_ACCOUNT_ID,'xml');
Step 4 : Check if the user has entered a phone number for us to call

Already have the users phone number in a database or otherwise? You’ll probably want to make changes to this step.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## If the phone number was just submitted send the request to Teleoh
if ($my_phone_number != '') {
 
    //Submit request for a TSV call to Teleoh and store the session variables. 
    $p = array("phone_number" => $country_code . $my_phone_number,"tsv_method" => "CALL","from_number" => "$from_phone_number","company_name" => "$company_name");  
    try{  $call_fire = $teleoh_api->TSV('Create',$p);  } catch(Exception $e) { $error = $e->getMessage(); }
 
    if ($error != '') { include 'requestphonenumber.php'; exit; }
 
    //If request was a success set session variables.
    $checksum = $call_fire->tsv->checksum;
    $request_id = $call_fire->tsv->request_id;
    $customer_verification_code = $call_fire->tsv->customer_verification_code;
 
    $_SESSION["teleoh_checksum"] = "$checksum";
    $_SESSION["teleoh_request_id"] = "$request_id";
    $_SESSION["customer_verification_code"] = "$customer_verification_code";
;
 
   //Once the session variables are set redirect to this page to show waiting screen while we wait for the user to verify.   
   header("Refresh:1; url=index.php");
   exit;
 
 }
Step 5 : If user has not provided a phone number include the request phone number page.
1
2
3
4
5
## Check if the user has submitted their phone number for verification, if not show the prompt page.
  if ($_SESSION["teleoh_checksum"] == '' && $_SESSION["teleoh_request_id"] == '') {
      include 'requestphonenumber.php'; exit;
  }
  ##
Step 6 : Once the TSV request has been submitted to Teleoh™ we can begin checking the status of the verification.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## If the session variables are set we show the waiting screen and check with Teleoh to see when the verification is completed.
  if ($_SESSION["teleoh_checksum"] != '' && $_SESSION["teleoh_request_id"] != '') {
 
    //Check the verification status.
    $p = array("request_id" => $_SESSION["teleoh_request_id"],"checksum" => $_SESSION["teleoh_checksum"]);  
    try{  $verify_tsv = $teleoh_api->TSV('Verify',$p);  } catch(Exception $e) { $error = $e->getMessage(); }
 
    //Verified Successful
    if ($verify_tsv->tsv->status == "1") {    
    $_SESSION["teleoh_checksum"] = "";
    $_SESSION["teleoh_request_id"] = "";
    $_SESSION["customer_verification_code"] = "";
    header("Refresh:1; url=$redirect_url"); 
    exit; 
    };
 
    //Verification Request Expired (5 minutes)
    if ($verify_tsv->tsv->status == "3") {    
    $_SESSION["teleoh_checksum"] = "";
    $_SESSION["teleoh_request_id"] = "";
    $_SESSION["customer_verification_code"] = "";
    print "Verification Request Expired";
    exit; 
    };
 
    //Verification Failed
    if ($verify_tsv->tsv->status == "4") {    
    $_SESSION["teleoh_checksum"] = "";
    $_SESSION["teleoh_request_id"] = "";
    $_SESSION["customer_verification_code"] = "";
    print "Verification Failed";
    exit; 
    };
 
    //Pending Verifiication / Show waiting screen
    if ($verify_tsv->tsv->status == "2") {    
    $show_code = $_SESSION["customer_verification_code"];
    header("Refresh:5; url=index.php");
    include 'wait.php';
	  exit;
    }; 
    if ($verify_tsv->tsv->status == "3") { echo "Request Expired"; exit; };
 
  }

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *