smichea.twilio
smichea.twilio
Features
- Send SMS messages using Twilio.
- Fetch details of sent SMS messages.
- Easy integration with Twilio API using basic authentication.
- Automatic parsing of Twilio's responses into Vlang structures.
Installation
To install
smichea.twilio
v install smichea.twilio
Usage
Before using the module, ensure you have set up your Twilio account and obtained your Account SID, Auth Token, and a Twilio phone number.
Setting Up
Import the module and initialize the
TwilioClient
import smichea.twilio
client := twilio.TwilioClient{
account_sid: '<your_account_sid>',
auth_token: '<your_auth_token>',
from_number: '<your_twilio_phone_number>',
api_version: '2010-04-01' // Optional, defaults to '2010-04-01'
}
Sending an SMS
To send an SMS:
result := client.send_sms('<recipient_phone_number>', '<message_body>') or {
println('Error sending SMS: $err')
return
}
println('SMS id (SID): ${result.sid}')
Fetching SMS Details
To fetch the details of a sent SMS by its SID:
sms_sid := '<sms_sid>'
details := client.fetch_sms(sms_sid) or {
println('Error fetching SMS details: $err')
return
}
println('SMS details: $details')
Contributions
Contributions to
smichea.twilio
License
This module is released under AGPLv3 licence. Please see the
LICENSE.txt