News:

  • April 30, 2026, 12:32:07 PM

Login with username, password and session length

Author Topic: Starting With HTTPCMD  (Read 20875 times)

trsimmons7

  • Jr. Member
  • **
  • Posts: 16
Starting With HTTPCMD
« 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

trsimmons7

  • Jr. Member
  • **
  • Posts: 16
Re: Starting With HTTPCMD
« Reply #1 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.....

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Starting With HTTPCMD
« Reply #2 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 assume in the Request, this would just include what I show.
  • I do not know if the leading "/" is needed in front of the "api" part.
  • You would have to replace the <YOUR_ACCOUNT_SID> with your relevant data as you show in your CURL coding.
  • Notice in the Additional User Request Header, I included authentication stuff. However, since your CURL coding doesn't show that you may not need it and that's why I have not checked it.
  • If the authorization is needed, then you'll have to replace the <Base64Encoded(AccountSID:AuthToken)> with what your is.
  • The $N part is translated by our OS as meaning carriage return line feed. This is also something I do not know if you need.
  • The portion "Content-Type: application/json" I'm not sure if that is needed either, nor if it goes in the Additional User Request Header portion, or the Request Body. This is something Twilio will also have to tell you.
  • In the Request Body, it is a bit different than your CURL coding because your coding is not truly in JSON format. So, I put it in JSON format. It looks very confusing simply because the $" is needed to get a double-quote within a string, so that our OS doesn't think the presence of a double-quote is the end of the string, since the static string is supposed to be contained within double quotes. I hope that makes sense.
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.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

Bolt

  • Hero Member
  • *****
  • Posts: 595
Re: Starting With HTTPCMD
« Reply #3 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.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Starting With HTTPCMD
« Reply #4 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.

Bolt

  • Hero Member
  • *****
  • Posts: 595
Re: Starting With HTTPCMD
« Reply #5 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.

trsimmons7

  • Jr. Member
  • **
  • Posts: 16
Re: Starting With HTTPCMD
« Reply #6 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

MarkTTU

  • Hero Member
  • *****
  • Posts: 293
    • SamJackson.com
Re: Starting With HTTPCMD
« Reply #7 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.