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


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
the php is up and working in this server

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

                $url = "$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
                // Closing

when I try in firefox,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:

# Core ID is 0123456789abcdef
# Your access token is 123412341234
curl \
  -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