curling twilio API

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

curling twilio API

rjd318
Hi all - can someone help me convert the following?

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

I just don't have any experience working with http(s) APIs and I've been
working through the forum posts as best I can. The only thing I've gathered
so far is using urlEncode for the --data-urlencode lines. Are the -X POST
and -u parts done in httpheaders?

Any help would be greatly appreciated - thanks!
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: curling twilio API

david williams
Hi Jose,

Off the top of my head, this would probably look something like the  
following in LC:

post tPostString to  
url("https://AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e@api*twilio*com/2010-04-01/Accounts/AC0afb9e5c70c0fde47904a9a6ff/Messages.json")

Where tPostString contains the post fields concatenated by & (for the  
example you posted):

To=5034554562&From=+1212022183&Body=test message

You can just sidestep this whole thing if you're on OSX/Linux by accessing  
curl directly with shell():

get shell("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")

I would also strongly advise against posting your API keys publicly and  
recommend you change the one you just posted, as there are bots which  
crawl the public-facing web for such keys.

-David

On Wed, 09 Sep 2015 12:24:19 +0100, Jose Damaso <[hidden email]> wrote:

> Hi all - can someone help me convert the following?
>
> 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
>
> I just don't have any experience working with http(s) APIs and I've been
> working through the forum posts as best I can. The only thing I've  
> gathered
> so far is using urlEncode for the --data-urlencode lines. Are the -X POST
> and -u parts done in httpheaders?
>
> Any help would be greatly appreciated - thanks!
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


--
Using Opera's mail client: http://www.opera.com/mail/

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: curling twilio API

rjd318
Thanks for the suggestions, David - especially about my keys (yikes!). I tried the format below and it seems to get further along as I don't get the authentication errors I saw previously. I receive an error that I need a 'FROM' although it's in the string.

> On Sep 9, 2015, at 8:49 AM, David Williams <[hidden email]> wrote:
>
> Hi Jose,
>
> Off the top of my head, this would probably look something like the following in LC:
>
> post tPostString to url("https://AC0afb9e5c70c0fde47904a9a6ff:e6a1bdc2a7a7484d6cdc96e@api*twilio*com/2010-04-01/Accounts/AC0afb9e5c70c0fde47904a9a6ff/Messages.json")
>
> Where tPostString contains the post fields concatenated by & (for the example you posted):
>
> To=5034554562&From=+1212022183&Body=test message
>
> You can just sidestep this whole thing if you're on OSX/Linux by accessing curl directly with shell():
>
> get shell("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")
>
> I would also strongly advise against posting your API keys publicly and recommend you change the one you just posted, as there are bots which crawl the public-facing web for such keys.
>
> -David
>
>> On Wed, 09 Sep 2015 12:24:19 +0100, Jose Damaso <[hidden email]> wrote:
>>
>> Hi all - can someone help me convert the following?
>>
>> 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
>>
>> I just don't have any experience working with http(s) APIs and I've been
>> working through the forum posts as best I can. The only thing I've gathered
>> so far is using urlEncode for the --data-urlencode lines. Are the -X POST
>> and -u parts done in httpheaders?
>>
>> Any help would be greatly appreciated - thanks!
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> --
> Using Opera's mail client: http://www.opera.com/mail/

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode