API function call: unknown variable

I have look here and on the web and I am sending this as a post from php but keep getting unknown variable.

$ch = curl_init();
                curl_setopt($ch, CURLOPT_URL,"https://api.particle.io/v1/devices/" . $deviceid . "/" . $pcall . "?access_token=" . $ptoken);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOP_POST, 1);
                curl_setopt($ch, CURLOP_POSTFIELDS, http_build_query(array('args' => $info)));

                $response = curl_exec( $ch );

$deviceid is the device
$pcall is the name of the function
$ptoken is the token for api
$info is the string I am sending to the function.

If you could show us the full code, and the full error, that’d be helpful. What variable is unknown? Where/when does it state that?

That is the full code.
the “unknown variable” is what particle sends back.

$pcall holds the text for the function. That is what is showing as unknown. I have seen several threads about this but no actual answer.

I believe @Moors7 is asking for the code running on the particle device you are trying to interact with.


It looks like you’re using a POST. POST is used to call a function. You need to use GET to query a variable.



I am not querying a variable. I am trying to call a function.

For lack of us seeing what code you’re using…

Particle.variable("temp", tempC);

You’d want to use temp, not tempC is case that’s what you’re doing now.

1 Like