Nooby trying "CONTROL LEDS OVER THE 'NET"

I’m having trouble with this example. I can compile and load the “Control LEDS over the net code” from the example just fine.
http://docs.spark.io/examples/

Now what am I supposed to do? I see the section saying “The API request will look something like this” but I have no idea where to run this code or where to control the blink of the LED from.

The rest of the example code is:
POST /v1/devices/{DEVICE_ID}/led

EXAMPLE REQUEST IN TERMINAL

Core ID is 0123456789abcdef

Your access token is 123412341234

curl https://api.spark.io/v1/devices/0123456789abcdef/led
-d access_token=123412341234
-d params=l1,HIGH

I don’t know what to do with this.

1 Like

Hi @jaysettle

The example is using a program called “curl” that runs on Windows/Mac/Linux/iOS and does HTTP and HTTPS web requests like a web broswer does but directly from the command line with no need to write HTML/Javascript etc. for a web page. curl is a great tool for testing but there are other choices like a web service called postman and quite a few others.

So get "curl’ from here and open up a shell/command/terminal window and try it.

1 Like

Ok great thanks. I’ve installed curl.

I open a cmd prompt. Cmd prompt keeps telling me whatever I type is not recognized. Is there something I can type to see if I’ve installed curl correctly?

Ok none of these work:
–ca

Displays the built-in path to the CA cert bundle this libcurl uses.

–cc

Displays the compiler used to build libcurl.

–cflags

Set of compiler options (CFLAGS) to use when compiling files that use libcurl. Currently that is only the include path to the curl include files.

–checkfor [version]

Specify the oldest possible libcurl version string you want, and this script will return 0 if the current installation is new enough or it returns 1 and outputs a text saying that the current version is not new enough. (Added in 7.15.4)

–configure

Displays the arguments given to configure when building curl.

–feature

Lists what particular main features the installed libcurl was built with. At the time of writing, this list may include SSL, KRB4 or IPv6. Do not assume any particular order. The keywords will be separated by newlines. There may be none, one, or several keywords in the list.

–help

Displays the available options.

–libs

Shows the complete set of libs and other linker options you will need in order to link your application with libcurl.

–prefix

This is the prefix used when libcurl was installed. Libcurl is then installed in $prefix/lib and its header files are installed in $prefix/include and so on. The prefix is set with “configure --prefix”.

–protocols

Lists what particular protocols the installed libcurl was built to support. At the time of writing, this list may include HTTP, HTTPS, FTP, FTPS, FILE, TELNET, LDAP, DICT. Do not assume any particular order. The protocols will be listed using uppercase and are separated by newlines. There may be none, one, or several protocols in the list. (Added in 7.13.0)

–static-libs

Shows the complete set of libs and other linker options you will need in order to link your application with libcurl statically. (Added in 7.17.1)

–version

Outputs version information about the installed libcurl.

–vernum

Outputs version information about the installed libcurl, in numerical mode. This outputs the version number, in hexadecimal, with 8 bits for each part; major, minor, patch. So that libcurl 7.7.4 would appear as 070704 and libcurl 12.13.14 would appear as 0c0d0e… Note that the initial zero might be omitted. (This option was broken in the 7.15.0 release.)

I guess I’ll try to re-install this.

I can see a curl folder in C:\Program Files\cURL. But if open cmd, none of the curl commands work. Not sure what else to do at this point.

what if you change to the program files/curl folder and then try them?

if it then works… You may need to define the path variable… a quick google should help with that, in summary

you will find in control panel - system… on the left hand pane… advanced system settings, advanced tab… environment variables button. click the path so its highlighted, then click edit, scroll to the end of whatever is in there, add a ; and then the path you listed above

1 Like

In the cmd window, I’ve changed directory to cd C:\Program Files\cURL.

Then I tried --vernum and --help with no luck.

That is great advice from @Hootie81 to check for a path issue.

You also know that you have to type:

  curl --version

on the cmd line. I wasn’t sure from your comment if you knew that the things after the dash or dash-dash are switched to the curl program, so you always have to start with curl.

Ok thanks.

I’ve open cmd and typed:
cd C:\Program Files\cURL

I then typed:
curl --vernum
with no luck

I then typed:
curl --help
no luck.

I’m using Windows 8 btw.

@jaysettle could you try going 1 more folder “cd bin” then try again
ie c:\Program Files\cURL\bin

1 Like

That worked thanks. Is this explained somewhere? How would I had ever know to do this?

thats where these forums are good

to make it easier, add the path variables as i described above but use the full path with the bin bit too

c:\Program Files\cURL\bin

then you can use curl from anywhere not just in the place the actual cURL file is located

Thanks for the super fast replies.

1 Like