Posts: 233
Threads: 71
Joined: Sep 2015
Reputation:
0
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Have a look here:
https://www.twilio.com/help/faq/twilio-b...-change-it
id_nr is your Account SID and token_nr is your Auth Token
Posts: 233
Threads: 71
Joined: Sep 2015
Reputation:
0
(02.03.2016, 12:29) admin Wrote: Have a look here:
https://www.twilio.com/help/faq/twilio-b...-change-it
id_nr is your Account SID and token_nr is your Auth Token
thank admin so much!
"
from_nr" and "to_nr" , what it?
thank all!
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
from_nr is Twilio number that is sending the message, in your Twilio account click "Get your first Twilio Number"
to_nr is the phone number that should receive the message
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
11.10.2019, 05:06
(This post was last modified: 23.10.2019, 06:20 by cuong.nguyen@vis.solutions .)
Hi,
I try to sent SMS by Twilio in VietNam as link:
https://openrb.com/notification-sms-from...desyntax_2
But, it's not working. I used this code for event:
from_nr = '+19177461563' -- Twilio phone number
to_nr = '+84932414151' -- My phone number
id_nr = '...' -- ACCOUNT SID
token_nr = '...' -- AUTH TOKEN
sms(id_nr, token_nr, to_nr, from_nr, 'Test SMS by SL'..tostring(value))
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
You have swapped from/to fields. It should be:
Code:
1
sms (
id_nr ,
token_nr ,
from_nr ,
to_nr ,
'Test SMS by SL' ..
tostring (
value ))
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
15.10.2019, 01:24
(This post was last modified: 15.10.2019, 01:25 by cuong.nguyen@vis.solutions .)
(11.10.2019, 06:52) admin Wrote: You have swapped from/to fields. It should be:
Code:
1
sms (
id_nr ,
token_nr ,
from_nr ,
to_nr ,
'Test SMS by SL' ..
tostring (
value ))
Same trouble
My Common Funtions:
Code:
1 2 3 4 5 6 7 8 9
function sms (
id ,
token ,
from ,
to ,
body )
local escape =
require (
'socket.url' ).
escape
local request =
require (
'ssl.https' ).
request
local url =
string.format (
'https://%s:%s@api.twilio.com/2010-04-01/Accounts/%s/Messages.json' ,
id ,
token ,
id )
local body =
string.format (
'From=%s&To=%s&Body=%s' ,
escape (
from ),
escape (
to ),
escape (
body ))
return request (
url ,
body )
end My Event:
Code:
1 2 3 4 5 6 7 8
value =
event.getvalue ()
from_nr =
'+19177461563'
to_nr =
'+84938354162'
id_nr =
'...'
token_nr =
'...'
sms (
id_nr ,
token_nr ,
from_nr ,
to_nr ,
'Test SMS by SL' ..
tostring (
value ))
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Replace
sms function with this one:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
function sms (
id ,
token ,
from ,
to ,
body )
local escape =
require (
'socket.url' ).
escape
local request =
require (
'ssl.https' ).
request
local url =
string.format (
'https://%s:%s@api.twilio.com/2010-04-01/Accounts/%s/Messages.json' ,
id ,
token ,
id )
local body =
string.format (
'From=%s&To=%s&Body=%s' ,
escape (
from ),
escape (
to ),
escape (
body ))
local resp = {}
local stat ,
code ,
hdrs =
request ({
method =
'POST' ,
url =
url ,
protocol =
'tlsv12' ,
sink =
ltn12.sink.table (
resp ),
source =
ltn12.source.string (
body ),
headers = {
[
'content-length' ] = #
body ,
[
'content-type' ] =
'application/x-www-form-urlencoded'
}
})
if stat then
stat =
table.concat (
resp )
end
return stat ,
code ,
hdrs
end
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
(15.10.2019, 13:53) admin Wrote: Replace sms function with this one:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
function sms (
id ,
token ,
from ,
to ,
body )
local escape =
require (
'socket.url' ).
escape
local request =
require (
'ssl.https' ).
request
local url =
string.format (
'https://%s:%s@api.twilio.com/2010-04-01/Accounts/%s/Messages.json' ,
id ,
token ,
id )
local body =
string.format (
'From=%s&To=%s&Body=%s' ,
escape (
from ),
escape (
to ),
escape (
body ))
local resp = {}
local stat ,
code ,
hdrs =
request ({
method =
'POST' ,
url =
url ,
protocol =
'tlsv12' ,
sink =
ltn12.sink.table (
resp ),
source =
ltn12.source.string (
body ),
headers = {
[
'content-length' ] = #
body ,
[
'content-type' ] =
'application/x-www-form-urlencoded'
}
})
if stat then
stat =
table.concat (
resp )
end
return stat ,
code ,
hdrs
end
It's working!! Thank you so much
But it takes about 15 min for 1 SMS, too long
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
You can try contacting Twilio support or ask your local operators if they provide SMS gateway service.
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
(16.10.2019, 10:38) admin Wrote: You can try contacting Twilio support or ask your local operators if they provide SMS gateway service.
Hi, I tried to send command with https with this code:
Code:
1 2 3 4
local http =
require (
'ssl.https' )
mime =
require (
"mime" )
res ,
err =
ssl.https.request (
'https://api.speedsms.vn/index.php/sms/send?access-token=...&to=84938354162&content=hello' )
log (
res ,
err )
Log message:
Code:
1 2 3 4
*
arg :
1
*
nil
*
arg :
2
*
string :
Try again
I can send this link from web browser. But, not working with LM5. Please check and tell me how to fix this?
Thanks
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Try updating LuaSocket library (System config > System > Packages > Add (+) green button)
New CPU:
https://dl.openrb.com/pkg/luasocket_2.0....9_imx6.ipk
Old CPU:
https://dl.openrb.com/pkg/luasocket_2.0....09_mxs.ipk
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
(18.10.2019, 12:36) admin Wrote: Try updating LuaSocket library (System config > System > Packages > Add (+) green button)
New CPU: https://dl.openrb.com/pkg/luasocket_2.0....9_imx6.ipk
Old CPU: https://dl.openrb.com/pkg/luasocket_2.0....09_mxs.ipk
Hi,
It's work on LM5. How's about the HL&SL? I don't see update packages function in System page
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
(21.10.2019, 09:21) admin Wrote: Install latest firmware
Hi,
I upgraded to ver 2.4.0. Still same trouble
Posts: 10
Threads: 0
Joined: Aug 2018
Reputation:
0
29.10.2019, 01:51
(This post was last modified: 29.10.2019, 02:52 by cuong.nguyen@vis.solutions .)
Hi,
How can I fix this trouble?? W4K and LM5 can work, SL can not
Thanks
Posts: 5030
Threads: 28
Joined: Aug 2017
Reputation:
230
SL is using all the same libraries as W4K as long you use the same version of FW. If it doesn't work your problem is elsewhere.
------------------------------
Ctrl+F5
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Check that your device has correct gateway and DNS set in System config > Network > Interfaces