Getting up on Twilio
Phil (OmnisList)
phil at pgpotter.co.uk
Wed Mar 8 15:22:18 UTC 2023
Hi Das,
I think that is:
OW3.$escapeuritext(cTextToEscape)
regards
Phil Potter
Based in Chester in the UK.
On 08/03/2023 14:53, Das Goravani wrote:
> Is there a function in Omnis that URLEncodes a string?
>
> Twilio needs you to repeat your ID number, once in the URI and again in a header.
>
> They told me ID and Token are together a header. With the -u in front.
>
> The problem with supplying a list for contents, is that you need to convert that to JSON to be readable, but they don’t accept JSON they told me. They said URL Encoded is all they accept. So I switched to the HTTPPost command which does URL Encoded for the contents list.
>
> Then again the worker has Authentication methods, basic being one of them , and that is what Twilio uses.
>
> If I could URL Encode my contents string then I could use the worker, try it.
>
> So far from Twilio when using HTTP Post I am getting the message that I’m unauthorized.
>
> When using the worker I get no reply from Twilio at all.
>
> There are some people on here up on Twilio. I wish they would reveal how they do it.
>
> Thanks so much for the help. You’re all URalL priceless.
>
> Das
>
>> On Mar 6, 2023, at 11:20 PM, Kelly Burgess<kellyb at montana.com> wrote:
>>
>> I see this sample:
>>
>> curl -XPOSThttps://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
>> --data-urlencode "To=+13105555555" \
>> --data-urlencode "From=+12125551234" \
>> --data-urlencode "MediaUrl=https://demo.twilio.com/owl.png" \
>> --data-urlencode "Body=Hello from my Twilio line!" \
>> -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
>>
>> This kind of implies that most or all of that stuff would be on one line.. the \ at the ends of lines means continue on same line..
>>
>> So that would mean you could send
>>
>> POSThttps://api.twilio.com/2010-04-01/Accounts/<yourID>/Messages.json?To=+13105555555&From=+12125551234&Body=Hello from my Twilio line!
>>
>> .. but you'd need to urlencode the spaces and exclamation mark in the body...
>>
>> I'm still thinking that the authToken would be passed in an Authorization: header. The userID is incorporated into the URL, so I'm not sure you'd need to repeat it in the arguments.
>>
>> Used to be easier before HTTPS - you could inspect the actual bytes sent down the wire to see how curl turned those arguments into a POST request. Once it's encrypted you can't see it, and I don't know how you'd get in to peek at it before it's encrypted. You'd need to set up a server, send a curl request to it, and examine what arrives at the server after it's decrypted.
>>
>> Kelly
>>
>>
>>> On Mar 6, 2023, at 3:16 PM, Kelly Burgess<kellyb at montana.com> wrote:
>>>
>>>> -u your_account_sid:your_auth_token
>>> You can run Terminal and type 'man curl' to get all the possible switches that curl recognizes.
>>>
>>> Example:
>>> curl -u user:secrethttps://example.com
>>>
>>> The -u switch isn't sent down the wire. I imagine the user name and password(authToken) would either be in some headers or in some inline arguments.
>>>
>>> Kelly
>>>
>>> -X, --request <command>
>>> (HTTP) Specifies a custom request method to use when communicating with
>>> the HTTP server. The specified request method will be used instead of
>>> the method otherwise used (which defaults to GET). Read the HTTP 1.1
>>> specification for details and explanations. Common additional HTTP
>>> requests include PUT and DELETE, but related technologies like WebDAV
>>> offers PROPFIND, COPY, MOVE and more.
>>>
>>> Normally you don't need this option. All sorts of GET, HEAD, POST and
>>> PUT requests are rather invoked by using dedicated command line options.
>>>
>>> This option only changes the actual word used in the HTTP request, it
>>> does not alter the way curl behaves. So for example if you want to make
>>> a proper HEAD request, using -X HEAD will not suffice. You need to use
>>> the -I, --head option.
>>>
>>> The method string you set with -X, --request will be used for all
>>> requests, which if you for example use -L, --location may cause
>>> unintended side-effects when curl doesn't change request method
>>> according to the HTTP 30x response codes - and similar.
>>>
>>> (FTP) Specifies a custom FTP command to use instead of LIST when doing
>>> file lists with FTP.
>>>
>>> (POP3) Specifies a custom POP3 command to use instead of LIST or RETR.
>>> (Added in 7.26.0)
>>>
>>> (IMAP) Specifies a custom IMAP command to use instead of LIST. (Added in
>>> 7.30.0)
>>>
>>> (SMTP) Specifies a custom SMTP command to use instead of HELP or VRFY.
>>> (Added in 7.34.0)
>>>
>>> If this option is used several times, the last one will be used.
>>>
>>> Examples:
>>> curl -X "DELETE"https://example.com
>>> curl -X NLSTftp://example.com/
>>>
>>>
>>> --data-urlencode <data>
>>> (HTTP) This posts data, similar to the other -d, --data options with the
>>> exception that this performs URL-encoding.
>>>
>>> To be CGI-compliant, the <data> part should begin with a name followed
>>> by a separator and a content specification. The <data> part can be
>>> passed to curl using one of the following syntaxes:
>>>
>>> content
>>> This will make curl URL-encode the content and pass that on. Just
>>> be careful so that the content doesn't contain any = or @
>>> symbols, as that will then make the syntax match one of the other
>>> cases below!
>>>
>>> =content
>>> This will make curl URL-encode the content and pass that on. The
>>> preceding = symbol is not included in the data.
>>>
>>> name=content
>>> This will make curl URL-encode the content part and pass that on.
>>> Note that the name part is expected to be URL-encoded already.
>>>
>>> @filename
>>> This will make curl load data from the given file (including any
>>> newlines), URL-encode that data and pass it on in the POST.
>>>
>>> name at filename
>>> This will make curl load data from the given file (including any
>>> newlines), URL-encode that data and pass it on in the POST. The
>>> name part gets an equal sign appended, resulting in
>>> name=urlencoded-file-content. Note that the name is expected to
>>> be URL-encoded already.
>>>
>>> Examples:
>>> curl --data-urlencode name=valhttps://example.com
>>> curl --data-urlencode =encodethishttps://example.com
>>> curl --data-urlencode name at filehttps://example.com
>>> curl --data-urlencode @fileonlyhttps://example.com
>>>
>>> See also -d, --data and --data-raw. Added in 7.18.0.
>>>
>>>
>>> -u, --user <user:password>
>>> Specify the user name and password to use for server authentication.
>>> Overrides -n, --netrc and --netrc-optional.
>>>
>>> If you simply specify the user name, curl will prompt for a password.
>>>
>>> The user name and passwords are split up on the first colon, which makes
>>> it impossible to use a colon in the user name with this option. The
>>> password can, still.
>>>
>>> On systems where it works, curl will hide the given option argument from
>>> process listings. This is not enough to protect credentials from
>>> possibly getting seen by other users on the same system as they will
>>> still be visible for a brief moment before cleared. Such sensitive data
>>> should be retrieved from a file instead or similar and never used in
>>> clear text in a command line.
>>>
>>> When using Kerberos V5 with a Windows based server you should include
>>> the Windows domain name in the user name, in order for the server to
>>> successfully obtain a Kerberos Ticket. If you don't then the initial
>>> authentication handshake may fail.
>>>
>>> When using NTLM, the user name can be specified simply as the user name,
>>> without the domain, if there is a single domain and forest in your setup
>>> for example.
>>>
>>> To specify the domain name use either Down-Level Logon Name or UPN (User
>>> Principal Name) formats. For example, EXAMPLE\user anduser at example.com
>>> respectively.
>>>
>>> If you use a Windows SSPI-enabled curl binary and perform Kerberos V5,
>>> Negotiate, NTLM or Digest authentication then you can tell curl to
>>> select the user name and password from your environment by specifying a
>>> single colon with this option: "-u :".
>>>
>>> If this option is used several times, the last one will be used.
>>>
>>> Example:
>>> curl -u user:secrethttps://example.com
>>>
>>>
>>>
>>>
>>>> On Mar 5, 2023, at 6:08 PM, Kelly Burgess<kellyb at montana.com> wrote:
>>>>
>>>> Hi Das,
>>>>
>>>> Binary is not an encoding. The JSON binaries are just ascii (utf-8) text. With unicode Omnis you need the binary to get single-byte characters for sending. When the JSON binary body goes over the wire, it's basically ascii or utf-8 text. URLencoding generally just means you replace any ampersands, percents, equal signs, etc. in the body with '%nn' equivalents, so as not to be misinterpreted as delimiters or special URL signifiers.
>>>>
>>>> Kelly
>>
> _____________________________________________________________
> Manage your list subscriptions athttps://lists.omnis-dev.com
> Start a new message ->mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list