L result = twilio_send_sms(pResult as p, to as c, message as c, namedResource as c [, from = "" , accountSID = "" , authCode = ""])
An object that contains return information provided by Twilio. For example, if the SMS fails ( result = .f.) the pResult object will have a property explaining why the SMS failed.
The number to send the SMS message.
The message to send.
The [Named Resource] that defines your Twilio settings.
Set to an empty string if you want to explicitly set the account SID, authorization token, and from arguments.
The phone number sending the message. Required if namedResource is an empty string.
Your Twilio account SID. Required if namedResource is an empty string.
Your Twilio authorization token. Required if namedResource is an empty string.
Returns .t. if the operation succeeds, otherwise .f.. twilion_send_sms() will return false if the Twilio endpoint cannot be reached or if Twilio reports an error. The pResult argument will contain additional details if an error occurs.
Send SMS messages from Xbasic to a mobile phone using Twilio. Requires a Twilio account and a phone number authorized to send SMS messages.
The twilio_send_sms() function sends an sms to a phone number using the Twilio messaging service.
Before you can use this function, you must first set up an account with Twilio. You must also own a phone number that is authorized to send SMS messages. Go to www.twilio.com to setup your Twilio account and learn more.
Once you have a Twilio account and phone number, Twilio will give you the following items that are needed to use the twilio_send_sms() function:
- Authorization Token
When you use the twilio_send_sms() function, you can either pass in the values for the account SID, the authorization token, and 'From' phone number explicitly, or you can create an entry in the Named Providers property in Project Properties to store these values and pass the name of the stored settings to the function (the named resource).
Using Named Resources is the preferred method because you can redefine any of the parameter values in the stored setting when you define a publishing profile.
If you explicitly set the accountSID, authCode and from arguments, set the namedResource argument must be set to an empty string.
pResult is an object that contains return information provided by Twilio. For example, if the SMS fails (twilio_send_sms() returns .f.) the pResult object will have a property explaining why the SMS failed.
See Resource Providers to learn how to create a named resource provider.
dim to as c to = "+15551111" dim message as c = "Sent from Xbasic at: " + now() dim namedResource as c = "MyTwilioSettings" dim pResult as p dim flag as l flag = twilio_send_sms(pResult,to,message,namedResource) 'to see what's in the pResult object showvarscript(pResult, "" + flag)