Page 1 of 1

Clickatell and LUA

Posted: Friday 24 February 2017 20:53
by Damnet
Dear all,

I'm trying to set-up an clickatell notifcitation.

Does someone know how you can make this cURL POST in LUA?
When browsing through other scripts I was only able to find an different HTTP calls 'http://api.clickatell.com/http/sendmsg?....."
Has something changed over time?

CURL CALL:
==========
curl -i \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: 2Y5zsIpqQyqImq6o308ctw==" \
-d '{"content": "Test Message Text", "to": ["+3161234567"]}' \
-s https://platform.clickatell.com/messages

Best regards

Re: Clickatell and LUA

Posted: Wednesday 01 March 2017 14:08
by Pico12
Hello,
for any shell command, you could call os.execute() :

Code: Select all

os.execute('echo "Hello" | nc localhost 12012');

Code: Select all

os.execute('curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: 2Y5zsIpqQyqImq6o308ctw==" -d \'{"content": "Test Message Text", "to": ["+3161234567"]}\' -s https://platform.clickatell.com/messages ");
Make sure to escape quotes.
Note that the command will be executed with sh (and not with bash).

Re: Clickatell and LUA

Posted: Friday 24 March 2017 22:28
by Damnet
Thanks it worked like a charm!! Escaping the quotes was something I was not able to figure out myself

Code: Select all

os.execute('curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: 2Y5zsIpqQyqImq6o308ctw==" -d \'{"content": "Test Message Text", "to": ["+3161234567"]}\' -s https://platform.clickatell.com/messages ')