Hi all, I'm having trouble trying to use the Twilio messaging API. This is my first attempt at this and I'm sure I'm reading other forums posts on how this is done and not comprehending correctly. Here's the CURL sample request that I am trying to convert
curl -X POST 'https://api*twilio*com/2010-04-01/Accounts/AC0afb9e5c70c0fde47904a9a6ff/Messages.json' \
--data-urlencode 'To=5034554562' \
--data-urlencode 'From=+1212022183' \
--data-urlencode 'Body=test message' \
-u AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e
... and so far I have ...
put urlEncode("To=8086306498") & "&" & \
urlEncode("From=+18082022182") & "&" & \
urlEncode(tMsg) into tParams
put URL "https://api*twilio*com/2010-04-01/Accounts/AC0afb9e5c70c0fde47904a9a6ff/Messages.json" & tParams into tResults
it seems like I am missing the conversion of the line '-u AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e' that is the account and auth token. Can someone point me in the right direction on how to supply the API with the -u piece? Or if I'm totally off on this, how it can be done? Thanks!
convert POST to livecode for twilio
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: convert POST to livecode for twilio
here's a few things to try...
first, you might need to use post instead of put, for example:
for the authorization I have 2 suggestions
1st, if this is just a token code you should be able to do this:
2nd, looking at the colon in the middle, it looks as though this is simply a user/password set up so you could try putting it and an "@" before the URL:
if #2 works, and you're security conscious then you can try the following:
first, you might need to use post instead of put, for example:
Code: Select all
post tPostData to URL (tURL)
put it into tResults
1st, if this is just a token code you should be able to do this:
Code: Select all
put "Authorization: Basic AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e" into tHeaders
set the httpheaders to tHeaders
Code: Select all
put urlEncode("To=8086306498") & "&" & \
urlEncode("From=+18082022182") & "&" & \
urlEncode(tMsg) into tParams
put URL "https://AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e@api.twilio.com/2010-04-01/Accounts/AC0afb9e5c70c0fde47904a9a6ff/Messages.json" & tParams into tResults
Code: Select all
put "Authorization: Basic"&&base64encode("AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e") into tHeaders
set the httpheaders to tHeaders
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know