Insert a variable into curl url


I wnat insert the device id and token into $url, and I tried the follow code, but receive error :
“error”: “Not Found”, “device_name”: and the same error to access token.

What is wrong?

    $url = ''.$deviceID.'/led/?      

This looks like PHP based on the syntax, so have you tried using the echo command to look at the result and the deviceID and accessToken variables?

Also you are doing a GET request for a Spark variable right? For a POST request you pass the access token as a parameter or use the bearer auth field.

1 Like

Yes, I can see the result using echo $deviceID and token. I need it to a POST.’

If I use this code works fine

$url = '';

You need to do it this way (from the docs):

curl \
  -d access_token=123412341234 \
  -d params=l1,HIGH

Notice how the access token is not part of the URL.