Clickatell and LUA

Moderator: leecollings

Post Reply
Damnet
Posts: 14
Joined: Friday 24 February 2017 20:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Clickatell and LUA

Post 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
Pico12
Posts: 1
Joined: Wednesday 01 March 2017 10:58
Target OS: Raspberry Pi / ODroid
Domoticz version: my own
Location: France
Contact:

Re: Clickatell and LUA

Post 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).
Damnet
Posts: 14
Joined: Friday 24 February 2017 20:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Clickatell and LUA

Post 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 ')
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest