User Tools

Site Tools


pvs:customdevkit_bulksms

This is an old revision of the document!


BulkSMS with the Custom Dev Kit

This page explains the necessary steps to integrate BulkSMS API gateway into Layer's PVS Module using the Custom Dev Kit.

Please Remember

  • $phone variable will be automatically supplied, and contains the customer's phone number
  • $code variable will be automatically supplied, and contains a 4 digit code

The Steps

  • Download the file below
  • Replace the authorization header - go to https://www.bulksms.com/account/#!/advanced-settings/api-tokens and generate a new token and paste the basic auth here
  • Overwrite the file customdevkit.php in the module's directory
  • Go to Setup → Addon Modules in WHMCS Admin
  • Click on Configure for Phone Verification System
  • Change the verification API to CustomDevKit
  • Save

File

The file below shows BulkSMS integrated using the Custom Dev Kit. Click here to download

customdevkit.php
<?php
#  Layer's Phone Verification System for WHMCS (Custom Dev Kit Example)
#
#  This file contains an example to help you integrate any SMS provider API's gateway. 
#  The example below shows how to integrate BulkSMS's API into Layer's PVS Module.
#  Please be advised that we do not provide support for custom integrations. 
#
#  $phone will be automatically supplied, and contains the customer's phone number
#  $code will be automatically supplied, and contains a 4 digit code
#
#  Example is provided below
#provide the content of the SMS message - remember to include the $code variable in your message, as that is the code to be sent to the customer
$body="Hello! The verification code is: ".$code.". Thank you for verifying your account!";
#build the API request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.bulksms.com/v1/messages');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Basic MkE3QTFBNzFFNEY0NDUxNDlGMjM2MjVEODFGQkEwNDktMDItNjpzIWEqSVM1Wk04aGpzRzZrNElBaCpDXXXXXXXXXX==',   // go to https://www.bulksms.com/account/#!/advanced-settings/api-tokens and generate a new token and paste the basic auth here                          
));
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'to' => $phone,
            'body' => $body,
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
#log the attempt to help troubleshoot
logModuleCall("myrskpvs","customdevkit-sms",$ch,$response);
?>
pvs/customdevkit_bulksms.1584804408.txt.gz · Last modified: 2020/03/21 16:26 by rsk