Twilio SMS

General questions about NeoBook

Moderator: Neosoft Support

ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Twilio SMS

Post by ajhunt »

Hi Guys and Gals, has anyone yet used the SMS feature of Twilio.com and intergrated it into any NeoBook App to send an SMS to mobile phone? I can't seem to get the params correct for the "InternetPost" command and any help would be greatly appreciated. Many thanks all.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Twilio SMS

Post by Gaev »

ajhunt:

1) Please post here details of the parameters you specified for the InternetPost command you are using (just change any sensitive values).

2) What kind of response did you get ?

3) If you are planning to have your publication used by others, note that it would be dangerous to have them use your credentials. It is for this reason that Twilio does not show any examples of using their APIs from a client side (like Javascript) ... just server side (like node.js, java, php etc.).
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

Hello Geav, thank you for your time yet again with helping. I have looked at the twilio website (https://www.twilio.com/docs/api/rest/sending-messages) at the Curl code but I just can't convert it for use with InternetPost. I have tried playing with it with the following:
https://api.twilio.com/2010-04-01/Accou ... }/Messages [To] [From] ][MessagingServiceSid] [BodyText] [MediaUrl] - and get a 401:UNAUTHORIZED return.
I've looked at the other examples like PHP but still can't work out how to use it within InternetPost.

I would like to be able to give uses option for sending either SMS or MMS (USA and Canada only) but not sure. They would be required to set it up with there own;
Twilio Phone#, Twilio AccountSID, Twilio AccountToken, Message and Country Code. The [BodyText] and [MediaUrl] I would add through the application.

Really hope you can help again Geav, but my skill set is definately not with api's. Many many thanks again Geav for any help or suggestions to help me achieve this.

Best regards Anthony.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Twilio SMS

Post by Gaev »

ajhunt:

I too had looked at the Curl code before my previous posting ... just wanted to make sure you did not have access to some other documentation.

I do not think that you can use NeoBook's InternetPost command to access Twilio's services. Looking at their Node.js, PHP, Python and Ruby code example, it looks like Twilio provides a custom "script library" for each of the platforms (your Application code then makes calls to functions within these libraries) ... with the NeoBook command, there is no way to specify these libraries.

You might be able to send simple (text only) messages with some work. Looking at the relevant lines in the cURL example they provide ...

Code: Select all

curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/Messages.json' \
--data-urlencode 'To=+16518675309'  \
--data-urlencode 'From=+14158141829'  \
--data-urlencode 'Body=Hey Jenny! Good luck on the bar exam!'
-u AC5ef872f6da5a21de157d80997a64bd33:[AuthToken]
... even if there are NeoBook plugins that will do the "urlencode" of the "From, To and Body" parameters ... I am not sure how to pass the equivalent of the "-u AC5ef872f6da5a21de157d80997a64bd33:[AuthToken]" line ... you might be able to pass them as separate "user=" and "password=" parameters ... or specify them as part of the url (see https://en.wikipedia.org/wiki/Uniform_Resource_Locator ).

I think you will have a better chance of success if you choose to interact with the website using the WebBrowser facility of NeoBook ... usually, libraries that are used with Node.js (server side) are usable on the client side (javascript) ... but only the people at Twilio can tell if this is the case with their library.

If you choose to go the WebBrowser route, you could ask their support people to provide you with a sample html file ... after that, it would be a simple case to have Neobook substitute the variable parameters and invoke an HTTPS request (using the POST method).

Otherwise, they could tell you if there was an alternative to the -u method for specifying your credentials (as I mentioned above).
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

Hi again Geav, many many thanks for your trying to help. I will contact Twilio support and see what they can suggest. I was hoping it would be straight forward but obviously not. Thanks again Geav for your expert time. Best regards Anthony.
TMcD
Posts: 239
Joined: Sun Apr 10, 2005 11:20 am

Re: Twilio SMS

Post by TMcD »

ajhunt wrote:Hi again Geav, many many thanks for your trying to help. I will contact Twilio support and see what they can suggest. I was hoping it would be straight forward but obviously not. Thanks again Geav for your expert time. Best regards Anthony.
Anthony,

What did they say? Where did this end up?

Thanks
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

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/Accou ... sages.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.
www.easyboothderby.co.uk/multicam

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

Best regards
Anthony
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

Re: Twilio SMS

Post by Tony Kroos »

Have you read this?
Note: If your use case require API Keys to access the /Accounts or /Keys endpoint, a Master Key needs to be used, which can be created in the Console.
I think you messed up api key, AccountSid and Token. If you provide access to your account I think I could take a look at your account setup and get your InternetPost request working.
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

Hi Tony, works perfectly -u [TwilioAccountNum]:[TwilioAuthCode] (I got this from the Twilio Support Team for use with curl)
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

Re: Twilio SMS

Post by Tony Kroos »

If it works with curl it must be working with InternetPost
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

More than likely it does Tony, but I just could not find the correct sequence - this worked so I though best leave it as working lol. If you can get it working with Internetpost then would be really great as would not have to install curl. Thanks for your time and replys Tony.
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

Re: Twilio SMS

Post by Tony Kroos »

I got an account but now I have to buy Twilio phone number to be able to send sms from it ?
TMcD
Posts: 239
Joined: Sun Apr 10, 2005 11:20 am

Re: Twilio SMS

Post by TMcD »

Tony Kroos wrote:I got an account but now I have to buy Twilio phone number to be able to send sms from it ?
Yes, you have to use their phone #. You can use your own, but you have to pay a fee for that.
ajhunt
Posts: 266
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom
Contact:

Re: Twilio SMS

Post by ajhunt »

Yes need to buy a phone number to use Twilio and then you use your TwilioAccountNum and TwilioAuthCode to send sms.
TMcD
Posts: 239
Joined: Sun Apr 10, 2005 11:20 am

Re: Twilio SMS

Post 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/Accou ... sages.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
Anthony,

Where are you getting the "curl.exe" software to run this from the desktop?

I too would like to use SMS. If we can't figure out Internet Post yet, then I don't have a problem using "curl.exe".

Thanks
Locked