►HowTo◄ Executing a CURL command - POSTing data

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2451
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

►HowTo◄ Executing a CURL command - POSTing data

Post by Jaymer »

(making a new thread - BWALK asked this Q in another thread and I didn't want to cutter that)

Had a phone conversation with Bill. In his app, he can start using CURL to accomplish what he wants.
You could also use Aware's REST ability to do this, but this is pretty easy for Bill to get running quickly.

Jaymer, I'm trying to get Twilio working in AwareIM, I have a few questions if you would be so kind.
1- how do you execute the Curl Command once you have built and saved it?
2- What is in SystemSetting.DQ?
It would be great to get Twilio working in AwareIM
Thanks, Bill
CREATE tempCurl WITH
tempCurl.theCommand=`curl -XPOST `+
`https://api.twilio.com/2010-04-01/Accou ... sages.json `+
` -d ~Body=` + YourBO.theSMSMessage +`~` +
` -d ~To=+1` + REPLACE_PATTERN(Contacts.Phone,'-','') +`~` +
` -d ~From=+18005551212` +`~` +
` -u AC95d46334f6xxxx4ee90eb23f78:2d8b0eb3bxxxx4f9e5c147b1`

NOTE: Am using a squiggle ~ instead of referring to SystemSetting.DQ, for readability. As an example, this makes the "from" line become this:
-d ~From=+18005551212~ which will become this:
-d "From=+18005551212" after the REPLACE_PATTERN below.


Then, replace all the squiggles with real double quotes, and execute. Examine the Server Output window to see the execution and possible any error msgs or return data.

tempCurl.theCommand = REPLACE_PATTERN( tempCurl.theCommand,'~', SystemSettings.DQ )

EXECUTE PROGRAM tempCurl.theCommand
Last edited by Jaymer on Tue Feb 05, 2019 5:24 pm, edited 2 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2451
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Executing a CURL command - POSTing data

Post by Jaymer »

Misc Notes:

1) The REPLACE on the TO # is needed in the event you store mask characters in your phone #. So you need to remove the dashes.

2) There are a few characters that will mess up an outgoing SMS message. I think one is a $. If you send a message like:
"The cost is $12"
I think the send will fail. There were a few gotchas I found and can't remember them all right now. I think you have to escape the $ with a '\', but thats not straightforward either. For now, I'd add a link to strip out any $ characters just in case.

3) If you bring up a popup window like "Enter the Message:" and allow the user to enter text, I think a CR to start a new line will also fail on a SMS.

4) SystemsSettings.DQ and .SQ hold double and single quote characters, respectively.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply