Curl from shell

Marty Knapp martyknappster at gmail.com
Fri Aug 14 19:03:15 EDT 2015


Thanks Richard,
I just solved it - I didn't have it formatted correctly for LC. In 
Terminal I could just enter:

curl -H "Accept: text/xml" 
https://API_KEY:API_SECRET@www.thewebsite.com/api/v1/data

In LC I had it formatted like this (it compiled):
get shell("curl -H" && "Accept: text/xml" && 
"https://API_KEY:API_SECRET@www.thewebsite.com/api/v1/data")

But it needed to be formatted like this (I neglected to use "quote"):
get shell("curl -H" && quote & "Accept: text/xml" & quote && 
"https://API_KEY:API_SECRET@www.thewebsite.com/api/v1/data")

Marty
> Marty Knapp wrote:
>
>> I'm trying to call curl from a shell command from within LC to get info
>> from a website via their API and am getting a "could not resolve host"
>> error. I can successfully run curl from the terminal (on Mac). This is
>> totally new territory for me, so I have almost no idea of what I'm
>> doing! I'm using LC 6.6.5 if that makes any difference.
>>
>> Here's the curl statement I'm using (formatted per the website's API):
>>
>> curl -H "Accept: text/xml"
>> https://API_KEY:API_SECRET@www.thewebsite.com/api/v1/data
>>
>> Works fine in Terminal. Note that it is using https if that matters.
>
> If it works in Terminal I'm mystified; Mark Wieder may have a tip for 
> that.
>
> Have you tested it with libURL?  For HTTP/HTTPS it shouldn't be 
> necessary to use curl or other outside programs.
>
> FWIW, I did some testing with wget yesterday (not the same as curl, 
> but often considered a bit lighter), and I found that the overhead of 
> instantiating the terminal session with shell meant that using libURL 
> was about 20% faster overall for downloading a 1MB binary data file.
>





More information about the use-livecode mailing list