hello every one, i am new to this area, i am trying to realize the web-connected led app, but i don’t know what to do at all after flash it into core. i read the document about the api but still have no idea how to send the commend. can anybody give me a detailed guidance on how to do it?
thanks
p.s. i am using osx
Using Particle-CLI might be a better idea. Open your terminal and follow the commands here:
hello, that is the api page i have been reading for hours,
for example, "GET /v1/devices"
shall i just type these in terminal?
This will be the command:
curl https://api.particle.io/v1/devices -d access_token=1234 -d id=0123456789abcdef01234567
thanks for the fast reply, i noticed this is the code given as an example for “POST /v1/devices”
btw, if i want to realize the web led thing, shall i type
curl https://api.particle.io/v1/devices/0123456789abcdef01234567/led
-d access_token=1234123412341234123412341234123412341234
-d “on”
(it doesn’t work)
and i know to substitute my own token and id ~
You are trying to call a function so:
curl https://api.particle.io/v1/devices/{DEVICE_ID}/{FUNCTION} -X POST -d access_token=1234 -d id=0123456789
where shall i put the commands “on”?
Opps…
curl https://api.particle.io/v1/devices/{DEVICE_ID}/{FUNCTION} -X POST -d access_token=1234 -d "params=on"
Maybe it is better to try and learn from this example: http://docs.particle.io/photon/examples/#control-leds-over-the-net-use
it works !!!
thanks
Consider Particle-cli. It’s much easier to use
Seeing as you'll eventually want to move past the command line, I'd recommend also reading this, it's been tremendously helpful in the past:
hello, thanks for the advice, i am trying to install cli. but
after i install node.js and type sudo npm install -g particle-cli,
following appears.
Failed at the serialport@1.7.4 install script ‘node-pre-gyp install --fallback-to-build’.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
i am using OS X, thanks
ping @Moors7
Moors7: no need to posts things double, if you want someone’s attention, simply tag them
@Moors7 thanks for editing, any idea on install error of cli?
Could you try npm install -g serialport
?
now it works !! thanks!
but both commands need to start with sudo.
Glad that it’s working. The sudo
part depends a bit on your operating system, and the rights you have on them. Generally, if something isn’t working, it’s worthwhile trying to sudo
it.
Dear Kenneth,
before searching in the forum, i try to type curl post request just like the tutorial
as bob said this doesn’t work.
i see that your command is slighly different, you add “-X POST” after function name. is the tutorial wrong or i’m missing something?
The doc samples usually work, but how does your own command actually look?
The extra verbosity of Kenneths command is not required but marks the fact that it is a POST request a bit better.
The overall format of the sample command is enough for curl to make it a POST.
The backslashes \
should not be entered - write it as on long command
And you might need sudo
if you’re on Linux or such.