Curl local cloud don't work [SOLVED: Install curl!]

Hello,

I’m trying send Curl command using local cloud, when I run the follow lines my server don’t receive request POST command

The variables #deviceID and $dispositivo already have the correct id and token

my server is 192.168.0.106
the php is up and working in this server

if I change the ip to spark cloud address, this lines works.

                $url = "http://192.168.0.106/v1/devices/$deviceID/led/?access_token=$dispositivo";
                //  Initiate curl
                $ch = curl_init();
                // Disable SSL verification
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                // Will return the response, if false it print the response
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                // Set the url
                curl_setopt($ch, CURLOPT_URL,$url);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, array('params' => 'l1,HIGH'));
                curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
                // Execute
                $result=curl_exec($ch);
                curl_exec($ch);
                // Closing
                curl_close($ch);

when I try in firefox
http://192.168.0.106:8080/v1/devices/54ff6e0666349058495430567/led/?access_token=34ad9d70e9a8a9bbc0d63f177c49834926516?params=l1,HIGH

I receive it:

{
“code”: 400,
“error”: “invalid_grant”,
“error_description”: “The access token provided is invalid.”
}

But the access token is correct.
Where is the problem?

Try passing the access token as a parameter instead of in the URL.

This is the curl command you are trying to do:

# 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 receive the same msg:
“error”: “invalid_token”,
“error_description”: “The access token provided is invalid.”

When I use “spark config identify” I can see the token and it’s ok

Thank you again, I found the problem. My apache don’t have the curl installed.

1 Like