Host Engineering Forum

General Category => General Discussion => Topic started by: trsimmons7 on November 13, 2023, 11:50:17 PM

Title: Starting With HTTPCMD
Post by: trsimmons7 on November 13, 2023, 11:50:17 PM
I'd like to see if I can send sms using my Twilio service - they've got reams of documentation, I just don't know where to start.

From the docs for CURL --

EXCLAMATION_MARK='!'
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
--data-urlencode "Body=This will be the body of the new message$EXCLAMATION_MARK" \
--data-urlencode "From=+15017122661" \
--data-urlencode "To=+15558675310" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

How do I format for the HTTPCMD instruction?

thanks
travis
Title: Re: Starting With HTTPCMD
Post by: trsimmons7 on November 27, 2023, 07:38:58 AM
I'd like to see if I can send sms using my Twilio service - they've got reams of documentation, I just don't know where to start.

From the docs for CURL --

EXCLAMATION_MARK='!'
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
--data-urlencode "Body=This will be the body of the new message$EXCLAMATION_MARK" \
--data-urlencode "From=+15017122661" \
--data-urlencode "To=+15558675310" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

How do I format for the HTTPCMD instruction?

thanks
travis

Its like crickets in here.....
Title: Re: Starting With HTTPCMD
Post by: Greg on December 14, 2023, 04:06:36 PM
trsimmons7, the only folks that would know for sure what this should look like will be the folks at Twilio. However, based on what I looked up (and I'm completely ignorant of their API protocol requirement), it looks like it should be similar to the pic. Although, I'll tell you what I do not know.
I do not have a Twilio account, so I cannot try this here at Host Engineering. You can experiment with this to see what works. Or you can get in touch with Twilio and see if they can help you with what parts go where in our HTTPCMD instruction.

I asked Bard (Google's AI), and he responded with:

Code: [Select]
POST https://api.twilio.com/2010-04-01/Accounts/<YOUR_ACCOUNT_SID>/Messages.json
Authorization: Basic <Base64Encoded(AccountSID:AuthToken)>
Content-Type: application/json
{
  "To": "+15555555555",
  "From": "+14155555555",
  "Body": "Hello from Twilio!"
}

Remember to replace <YOUR_ACCOUNT_SID> and <Base64Encoded(AccountSID:AuthToken)> with your actual account details. You can find these details in your Twilio account dashboard.
Title: Re: Starting With HTTPCMD
Post by: Bolt on December 14, 2023, 05:17:59 PM
I have tried to do a an HTTPCMD to Twilio in the past, and had no luck. I can get it to work through Postman, but not DmD, so not sure where I go wrong. Typically, I would have the "api.twilio.com" in the Server Name, and then "/2010-04-01/Accounts/<YOUR_ACCOUNT_SID>/Messages.json" in the Request. Last time I used HTTPCMD, I couldn't get the "Content-Type: application/json" to work in the Additional Header (but now that I see this, I was doing $0D$0A, not $N between the Auth-Token and Content-Type). I had to put it in the checkbox at the bottom.

Perhaps MarkTTU will chime in here, I think he has done something similar to this.
Title: Re: Starting With HTTPCMD
Post by: franji1 on December 15, 2023, 09:27:00 AM
(but now that I see this, I was doing $0D$0A, not $N between the Auth-Token and Content-Type).

FYI, entering "$N" for a string literal in the editor just expands to "$0D$0A" once you enter the instruction into your rung.
Title: Re: Starting With HTTPCMD
Post by: Bolt on December 15, 2023, 11:42:17 AM
FYI, entering "$N" for a string literal in the editor just expands to "$0D$0A" once you enter the instruction into your rung.

Ha, and here all these years I've been typing 6 characters instead of 2... All courtesy of the typewriter.
Title: Re: Starting With HTTPCMD
Post by: trsimmons7 on February 05, 2024, 09:49:36 AM
Thanks for the posts guys - I haven't had a chance to circle back to this one yet.

thx
travis
Title: Re: Starting With HTTPCMD
Post by: MarkTTU on February 23, 2024, 10:52:26 PM
Sorry to be late to the party on this one. I've never managed to get Twilio to work directly with a DmD PLC. In the past I had an intermediate server that the DmD PLC would post to via an API we wrote and then that intermediate server connected to Twillo.

More recently I setup doing SMS directly from a DmD PLC using Telnyx. Got that up and running in an afternoon. Overall I actually prefer Telnyx service now that I've discovered it and used it a bit. Might be a touch cheaper as well. If you're going to be doing any volume of SMS you'll want to get a toll-free number to send from; they're the same price, but the carriers allow for much higher message sending rates from toll free numbers.