To use SMS API, you need to register an account at: https://connect.speedsms.vn.
Each registered account will be provided an API access token. Your apps will use this token to authenticate with SpeedSMS API
To get API access token, you need to log in at: https://connect.speedsms.vn, Access to menu category: "Settings" select "Profile"
Below is the instruction on how to integrate SpeedSMSAPI into your code:
/*
* Firstly, you need to include SpeedSMS's library by inserting the following code lines:
*/
require("SpeedSMSAPI.php");
/**
* Then, create an instance of SpeedSMSAPI class and pass your parameter into api access token.
*/
$smsAPI = new SpeedSMSAPI("Your access token");
/**
* To get information into your account like email, account balance, you need to use the function: getUserInfo()
*/
$userInfo = $smsAPI->getUserInfo();
/* * GetUserInfo() will return the result as follows:
* /
["email"=>"[email protected]", "balance" =>100000.0, "currency" => "VND"]
/** To send sms, you use the function of sendsms as follows :
*/
$phones = ["8491xxxxx", "8498xxxxxx"];
/* up to 100 phone numbers for one time of API calling */
$content = "test sms";
$type = sms_type
/**
sms_type has the following values:
2: message sent by random phone number
3: message sent by branndname
4: message sent by default brandname (verify or notify)
5: message sent by android app
*/
$sender = "brandname";
/**
brandname is a kind of brand or phone number that is registered with SpeedSMS*/
$response = $smsAPI->sendSMS($phones, $content, $type, $sender);
/**SendSMS will return the result as follows:*/
[
"status"=>"success", "code"=> "00",
"data"=>[
"tranId"=>123456, "totalSMS"=>2,
"totalPrice"=>500, "invalidPhone"=>[]
]
]
*/
// In case of failing to send voice otp, the function will return the result as follows:
[
"status"=>"error", "code"=>"error code", "message" => "error description",
"invalidPhone"=>["A list of failed number"]
]
/** To send VOICE OTP, you use sendvoice function as follows:
*/
$phone = "8491xxxxx";
$content = "xxxx";
/* The content only contains the code,ex: 1234 */
$response = $smsAPI->sendVoice($phone, $content);
/**Sendvoice will return the result as follows::*/
[
"status"=>"success", "code"=> "00",
"data"=>[
"tranId"=>123456,
"totalPrice"=>400, "invalidPhone"=>[]
]
]
*/
// In case of failing to send voice otp, the function will return the result as follows:
[
"status"=>"error", "code"=>"error code", "message" => "error description",
"invalidPhone"=>["a list of failed number"]
]
We are worried about whether customers receive messages or not in case we send important information to clients. SpeedSMS will help you tackle this problem with the feature of Delivery status report. When messages are sent successfully or failed to send (in case mobile phone runs out of battery or is out of coverage area) to customers, SpeedSMS will inform you by sending a HTTP Post to url address that you have given to SpeedSMS (known as Webhook).
To use the feature of delivery report, firstly you need to log in dashboard page at http://connect.speedsms.vn. Select menu Setting ->Webhook , then declare an url address to receive request from SpeedSMS when messages are sent successfully to customers.
When messages are sent successfully to customers, SpeedSMS will send a HTTP Post to an url that you have provided: {"type": "report", "tranId": "transaction id", "phone": "phone number", "status": "status success/failed"} including:
Like delivery report, you need to declare an url address to receive request from SpeedSMS when customers send feedback message to you.
When receiving feedback messages from customers, SpeedSMS will send a HTTP Post to an url address that you have provided: {"type": "sms", "phone": "phone number", "content": "sms content"} Including: