Page 2 of 2

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 2:31 pm
by Tony Kroos
Can Neosoft Support describe how exactly [HTTPUserID] [HTTPUserPassword] global vars are handled with SSL connection? Does it send properly constructed Authorisation header or what?

It fails with httpS protocol, I had success with HTTP call (but it's unsecure):
SetVar "[HTTPUserID]" "AC7d1dda8acb482a6fec7de3e9a841cxxxxxxx"
SetVar "[HTTPUserPassword]" "4e6813223f8aa96fa5226a3cbbxxxxxxxx"
InternetPost "http://api.twilio.com/2010-04-01/Accounts/AC7d1dda8acb482a6fec7de3e9a841xxxxxxx/Messages.json" "To%3D%2B166234311042%26From%3D%2B18722282225%26Body%3D12113" "[result]" ""

Result - http://imgur.com/a/CMzxN but still cannot send sms via http request, maybe because of non-secure connection

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 2:40 pm
by ajhunt
Hi TMcD, I download from: https://curl.haxx.se/dlwiz (executable, Windows/Win32, Generic, Any). If needed I can upload for you to download. :)

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 3:02 pm
by TMcD
Tony Kroos wrote:Can Neosoft Support describe how exactly [HTTPUserID] [HTTPUserPassword] global vars are handled with SSL connection? Does it send properly constructed Authorisation header or what?

It fails with httpS protocol, I had success with HTTP call (but it's unsecure):
SetVar "[HTTPUserID]" "AC7d1dda8acb482a6fec7de3e9a841cxxxxxxx"
SetVar "[HTTPUserPassword]" "4e6813223f8aa96fa5226a3cbbxxxxxxxx"
InternetPost "http://api.twilio.com/2010-04-01/Accounts/AC7d1dda8acb482a6fec7de3e9a841xxxxxxx/Messages.json" "To%3D%2B166234311042%26From%3D%2B18722282225%26Body%3D12113" "[result]" ""

Result - http://imgur.com/a/CMzxN


Great question.

I think it may be in the way that you are setting up your request. (I haven't tried it with Twilio yet), but here is why I say this:

In a normal "Post", you need to send along the Vars [HTTPUserID] and [HTTPUserPassword] as part of the data in the "Data to post to server (optional)".

The reason why it went through without SSL, I'd guess is because no username/password is needed.

I tested if NeoBook can send via SSL, and it looks like it. (I'm not a complete nerd), but I tested sending to a SSL connection and it was received with the data I sent.

I used https://www.requestb.in

Here is my NeoBook Code:

Code: Select all
SetVar "[HTTPUserID]" "nancy123"
SetVar "[HTTPUserPassword]" "applesauce"
SetVar "[Data]" "username=[HTTPUserID]&password=[HTTPUserPassword]"
InternetPost "https://requestb.in/1cckR0z9" "[Data]" "[HTTPSResult]" "Async"


Here is what Requestb.in replied/showed:

HEADERS

X-Request-Id: d364f8d3-d2b9-48d1-a388-348983c93b2a
Cf-Visitor: {"scheme":"https"}
Accept: */*
Cf-Ray: 395a7fca4a5a20ae-LAX
User-Agent: Untitled NeoBook Publication
Host: requestb.in
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
Cookie: __cfduid=d86b96f64ffb66d7885d073f8a053b4691503956846
Cf-Connecting-Ip: 64.209.224.33
Connection: close
Via: 1.1 vegur
Connect-Time: 0
Total-Route-Time: 0
Content-Length: 37
Cf-Ipcountry: US

----- ----- ----- ----- ----- ----- ----- ----- ----- -----

FORM/POST PARAMETERS

password: applesauce
username: nancy123

----- ----- ----- ----- ----- ----- ----- ----- ----- -----

RAW BODY

username=nancy123&password=applesauce

----- ----- ----- ----- ----- ----- ----- ----- ----- -----
----- ----- ----- ----- ----- ----- ----- ----- ----- -----
----- ----- ----- ----- ----- ----- ----- ----- ----- -----

Let's get this figured out, as I too want to use Twilio in an upcoming project, AND I want NeoBook to continue to rock! :D

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 9:47 pm
by TMcD
ajhunt wrote:Hi TMcD, I download from: https://curl.haxx.se/dlwiz (executable, Windows/Win32, Generic, Any). If needed I can upload for you to download. :)


Thanks, I just grabbed it.

A couple of things:

1. Will a Windows32 version of curl.exe work on a 64Bit machine?

2. Any way to hide the prompt window?
I tried a few things and I couldn't hide it or run it in a rectangle. (don't want end user to see, if possible).
* I didn't get Twilio setup, just tried running the curl.exe alone.

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 10:01 pm
by TMcD
Tony Kroos wrote:Can Neosoft Support describe how exactly [HTTPUserID] [HTTPUserPassword] global vars are handled with SSL connection? Does it send properly constructed Authorisation header or what?

It fails with httpS protocol, I had success with HTTP call (but it's unsecure):
SetVar "[HTTPUserID]" "AC7d1dda8acb482a6fec7de3e9a841cxxxxxxx"
SetVar "[HTTPUserPassword]" "4e6813223f8aa96fa5226a3cbbxxxxxxxx"
InternetPost "http://api.twilio.com/2010-04-01/Accounts/AC7d1dda8acb482a6fec7de3e9a841xxxxxxx/Messages.json" "To%3D%2B166234311042%26From%3D%2B18722282225%26Body%3D12113" "[result]" ""

Result - http://imgur.com/a/CMzxN but still cannot send sms via http request, maybe because of non-secure connection


Are you sure you got Twilio to send you a Text on the unsecure URL?

I tried it, replacing my Auth, my "To" number, etc. still get the 401 error (Unauthorized).

Re: Twilio SMS

PostPosted: Mon Aug 28, 2017 11:46 pm
by TMcD
ajhunt wrote:Hi TMcD, found a solution by installing and using C++ runtime and Curl. Basically upload file to FTP site location so hosted, then send the text message via Curl to number tapped in by user. User receives SMS in about 30 seconds. Cut out of action commands as below.

1. SetVar "[FilenameToSend]" "[DateTimeStamp].mp4"

2. fmCopyTo "FTPConnection" "[TempFolder][FilenameToSend]" "GetConfirmation=No;ShowProgress=No"

3. SetVar "[DownloadLink]" "[FTPWebAddress]/[FTPFolder]/[EventTitle]/[FilenameToSend]"

4. FileWrite "[TempFolder]Batch.bat" "All" "[PubDir]Tools\curl.exe -s -XPOST https://api.twilio.com/2010-04-01/Accounts/[TwilioAccountNum]/Messages.json -d [#34]Body=[TwilioMessage] [DownloadLink][#34] -d [#34]To=+[CountryCode][SMSNumber][#34] -d [#34]From=[TwilioCountryCode][TwilioFromNum][#34] -u [TwilioAccountNum]:[TwilioAuthCode]"

You can download my photobooth app to see it working after setting up your own FTP and Twilio account.
http://www.easyboothderby.co.uk/multicam


Hope this helps and anyone who wants to do the same.

Best regards
Anthony


Hey Anthony,

Well after a few hours with what seems like hundreds of iterations, I can't get Twilio to send me a text. :roll:

Here is the clean code that should work (again I tried many variations when this did not work):

Code: Select all
... Test Details:
SetVar "[AccountSid]" "ACa8844beb27139eb4769902a3e88fd3c9"
SetVar "[AuthToken]" "c100g98016f99e5e282d4a0a93121b70"
SetVar "[to]" "18015258998"
SetVar "[from]" "18015258998"
SetVar "[message]" "Twilio"
FileWrite "[PubDir]Batch.bat" "All" "[PubDir]curl.exe -s -XPOST https://api.twilio.com/2010-04-01/Accounts/[AccountSid]/Messages.json -d [#34]Body=[message][#34] -d [#34]To=+[to][#34] -d [#34]From=+[from][#34] -u [AccountSid]:[AuthToken]"
Delay "250"
Run "[PubDir]Batch.bat" "" "Normal" "" ""


Notes:

1. curl.exe is in the [PubDir]
2. That is not my real phone number above (but only for this post).
3. That is not my SID or Token (but only for this post).
4. Seems straight forward, but it's not working.
5. I am using a testing account, not a paid account (at the moment) (It still has $29.00 credit).

Thanks

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 3:10 am
by Tony Kroos
. I am using a testing account, not a paid account (at the moment) (It still has $29.00 credit).

Have you got a proper phone number to send sms "from" at twilio account settings?

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 3:24 am
by TMcD
Tony Kroos wrote:
. I am using a testing account, not a paid account (at the moment) (It still has $29.00 credit).

Have you got a proper phone number to send sms "from" at twilio account settings?


Yes, I have a proper phone number and have sent myself a text using their site, but via NeoBook, it's a "no go" :lol:

I'm gonna look at it again later on.

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 4:39 am
by ajhunt
Hi, I'll be back in my office tomorrow and send you more details

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 5:18 am
by Gaev
TMcD:

Some debugging suggestions ...

1) using notepad.exe (or your favourite text editor), take a look at Batch.bat ... is it composed the way you expected it to ?

2) if it is properly composed, try and run Batch.bat ... either from the command prompt (DOS) or directly from the File Manager (a.k.a Windows Explorer)

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 5:48 am
by Tony Kroos
Can Neosoft Support describe how exactly [HTTPUserID] [HTTPUserPassword] global vars are handled with SSL connection? Does it send properly constructed Authorisation header or what?

Since there's no light has been shed on this, I had to develop simple plugin for handling SSL POST request for twilio api. Maybe I make it generic if anyone else need this for another api-s.
Will post a download link later today.

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 8:23 am
by Tony Kroos
Check it out - Download

You must create valid authorization string with "dmBase64Encode" before making any requests, then you may store this string inside your pub and use it.

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 10:57 am
by HPW
Hello Tony,

Only for the interested plugin developer: What enviroment/language do you use for your plugin development?

Regards

Re: Twilio SMS

PostPosted: Tue Aug 29, 2017 2:49 pm
by ajhunt
As Gaev says, make sure your Batch.bat is being written correctly:

FileWrite "[TempFolder]Batch.bat" "All" "[PubDir]Tools\curl.exe -s -XPOST https://api.twilio.com/2010-04-01/Accounts/[TwilioAccountNum]/Messages.json -d [#34]Body=[TwilioMessage] [DownloadLink][#34] -d [#34]To=+[CountryCode][SMSNumber][#34] -d [#34]From=[TwilioCountryCode][TwilioFromNum][#34] -u [TwilioAccountNum]:[TwilioAuthCode]"

Run "[TempFolder]Batch.bat" "" "RunOnce+Wait+Hidden" "" ""

FileErase "[TempFolder]Batch.bat"

Re: Twilio SMS

PostPosted: Wed Aug 30, 2017 1:51 am
by ajhunt
If still need to send sms and cannot get twilio to intergrate then an alternative can be: SMSCmd at http://www.sms4mail.com/smsmail/smscmd1.htm - sends via command line so easy intergration into projects as write as batch file and run - a little more expensive but if needs must