dont understand Curl

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

dont understand Curl

Post by adventuresofgreg » Mon Oct 22, 2018 8:51 pm

Hey there. I'm trying to authenticate a Stripe transaction with LC script, and Yp totally don't understand Curl. According to the Stripe api guide, this is what I need to post to the stripe api URL:

curl https://api.stripe.com/v1/charges \
-u sk_test_123456ABCDEFG: \
-d amount=999 \
-d currency=usd \
-d description="Example charge" \
-d source=tok_visa

Tried POST ing that data a million ways to the URL, and I get nothing back. Can someone help?

Cheers,
Greg

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: dont understand Curl

Post by jacque » Tue Oct 23, 2018 9:30 pm

Curl is a shell command, did you try that?

For POST you'd need something like this:

Code: Select all

put "sk_test_123456ABCDEFG?amount=999&currency=usd&description=Example charge&source=tok_visa" into tCmd
post tCmd to "https://api.stripe.com/v1/charges"
But I'm not quite sure where the "?" should go, it depends on what the server expects. It might need to be at the beginning instead of after the "sk_test" entry.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: dont understand Curl

Post by adventuresofgreg » Tue Oct 23, 2018 10:34 pm

Thank you. I tried something like your POST command, but didn't have a "?" in there. I'll give that a shot. But reading around - doesn't a Curl command require some kind of header?

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: dont understand Curl

Post by adventuresofgreg » Tue Oct 23, 2018 10:39 pm

tried that post and it doesn't work. How would I send this as a shell command?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: dont understand Curl

Post by jacque » Tue Oct 23, 2018 11:03 pm

I'm not sure how the flags will impact it, but basically you can put the whole string into a variable and then:

get shell(tVar)

See the shell function in the dictionary. There's several examples there.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: dont understand Curl

Post by adventuresofgreg » Wed Oct 24, 2018 12:43 pm

field "stripeCurl" =

$ curl https://api.stripe.com/v1/charges \
-u sk_test_abc123: \
-d amount=999 \
-d currency=usd \
-d description="Example charge" \
-d source=tok_visa

My code:
get shell(field "stripeCurl")
put it

I get error:
/bin/sh: line 1: command not found

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: dont understand Curl

Post by Klaus » Wed Oct 24, 2018 5:55 pm

Leave out the $!

Code: Select all

curl https://api.stripe.com/v1/charges ...
Should do the trick.

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: dont understand Curl

Post by adventuresofgreg » Wed Oct 24, 2018 11:35 pm

oh my god Klaus! Thats it. I was so shocked to see my it that didn't just say error, that it actually scared me a bit! Thanks!

Next question: I need to run this from lc server on Linux. My standard shell command should work right?

Post Reply

Return to “Internet”