Logic Machine Forum
SMS text via DWR-921 4G LTE Router - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: SMS text via DWR-921 4G LTE Router (/showthread.php?tid=103)



SMS text via DWR-921 4G LTE Router - gtsamis - 10.10.2015

Hello,
Has anyone tryied to use the Dlink DWR-921 4G LTE Router as SMS gateway for LM?
It only has a web interface and i haven't being able to find any API.


RE: SMS text via DWR-921 4G LTE Router - admin - 12.10.2015

Sending SMS should be possible via a HTTP request from LM. You just need to know the correct URL and GET/POST variables. You can view the full request in your browser developer tools by pressing F12 and switching to Network tab.


RE: SMS text via DWR-921 4G LTE Router - gtsamis - 14.10.2015

I am a bit stuck here  Confused Confused

I have managed to trace the login and send sms URLs but I can't replicate them outside the routers web interface.

Is seems to authenticate with the login URL but when i post the send sms URL i got the OK reply but the message never sends.
I have attached the HTTP posts/replies from routers web interface that used in order to login and send a test sms.

Quote:Line 243
GET http://192.168.16.1/log/in?un=admin&pw=password&rd=%2Fuir%2Fstatus.htm&rd2=%2Fuir%2Fwanst.htm&Nrd=1

Line 442 
GET http://192.168.16.1/smsmsg.htm?Nsend=1&Nmsgindex=0&S801E2700=6979555555&S801E2800=Test%20send%20sms


Any help would be much appreciated.


RE: SMS text via DWR-921 4G LTE Router - admin - 15.10.2015

Have you tried sending these requests from your browser or from LM?


RE: SMS text via DWR-921 4G LTE Router - gtsamis - 16.10.2015

(15.10.2015, 07:28)admin Wrote: Have you tried sending these requests from your browser or from LM?


First off all i figure out that it needs a third post in order to send the sms (GET http://192.168.16.1/sms2.htm?Ncmd=2
I have tested it from several browsers and from LM and it works just for the first time.
I think it has to do with cookies... 

On my http sniffer i get some changes everytime i login on routers web interface. The header has a definition "cookies" (AMSESSIONID) that changes in every session.
Now I think i need a way to grab that AMSESSIONID and use it on further requests.



Code:
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,el;q=0.6
Cookie: ID=AMIT0000; AMSESSIONID=7737225
DNT: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36



Code:
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,el;q=0.6
Cookie: ID=AMIT0000; AMSESSIONID=8449948
DNT: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36



RE: SMS text via DWR-921 4G LTE Router - admin - 16.10.2015

Your first request to login URL should look like this:
Code:
res, code, hdr = socket.http.request('http://...')
if hdr['set-cookie'] then
  cookie = hdr['set-cookie']:split(';')[ 1 ]
end

All further requests must pass the cookie received from the first request:
Code:
res = socket.http.request({
  url = 'http://...',
  headers = {
    Cookie = cookie
  }
})