
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
thaibulksms-api
Advanced tools
npm install thaibulksms-api
or
yarn add thaibulksms-api
วิธีเรียกใช้
const thaibulksmsApi = require('thaibulksms-api')
OTP หรือ One Time Password คือ รหัสผ่านที่ได้รับจากข้อความ(SMS) ในมือถือ เพื่อความปลอดภัยในการยืนตัวตนการเป็นเจ้าของ ในทำธุระกรรมทองอินเทอร์เน็ต ซึ่งรหัสผ่านจะมีอายุในการยืนยันตามที่ได้ตั้งค่าไว้
OTP API ของ ThaibulkSms จะมี 2 ส่วนให้เรียกใช้งาน ดังนี้ (ตามในคู่มือการใช้งาน OTP API)
Request OTP คือ การส่งคำขอสร้างรหัส OTP ซึ่งจะใช้แค่เพียงเบอร์โทรอย่างเดียว ก็สามารถสร้างรหัส OTP ได้ โดยรหัสจะส่งผ่านข้อความ SMS
//ทำการเรียกฟังนี้ ก็สามารถส่งรหัสได้
const response = await otp.request(phoneNumber)
//ตัวอย่างข้อความที่ได้รับ
/*
TBS Code: 093892. Valid for 5 minutes.
*/
ตัวอย่างโค้ด
const thaibulksmsApi = require('thaibulksms-api')
const options = {
apiKey: 'App key',
apiSecret: 'App secret',
}
const otp = thaibulksmsApi.otp(options)
const requestOTP = async (phoneNumber) => {
try {
const response = await otp.request(phoneNumber)
console.log(response.data)
} catch (error) {
console.error(error)
}
}
requestOTP('06xxxxxxxx')
// Response success
/*
{
data: {
status : "string",
token : "string"
}
}
*/
// Response fail
/*
{
code: 400,
statusText: 'Bad Request',
message: {
detail: {
...
},
message: 'Invalid Paramete.'
}
}
*/
Verfiy OTP คือ การนำเอารหัส OTP ที่ได้จาก SMS มาตรวจสอบว่ารหัสถูกต้องหรือไม่
//ทำการเรียกฟังนี้ ก็สามารถส่งรหัสได้
const response = await otp.verify(token, code_OTP)
// token ได้จากตอนที่ตอนขอ request otp
// code_OTP ได้จากข้อความ SMS
ตัวอย่างโค้ด
const verifyOTP = async (token, code_OTP) => {
try {
const response = await otp.verify(token, code_OTP)
console.log(response.data)
} catch (error) {
console.error(error)
}
}
verifyOTP('a12ec2lo-wladkeoDWelso3044', 1234)
// Response success
/*
{
"data": {
"status": "success",
"message": "Code is correct."
}
}
*/
// Response fail
/*
{
code: 400,
statusText: 'Bad Request',
message: { detail: [], message: 'Token is expire.' }
}
*/
Options
Value | Type | Required | Notes |
---|---|---|---|
apiKey | String | Yes | Key of application. |
apiSecret | String | Yes | Secret of application. |
FAQs
วิธีส่ง SMS ง่ายๆด้วย Thaibulksms API ทั้งแบบข้อความและ OTP
The npm package thaibulksms-api receives a total of 233 weekly downloads. As such, thaibulksms-api popularity was classified as not popular.
We found that thaibulksms-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.