Help with CURL
When I manually open the link in a browser, I get the correct status based on the door position. It seems that CURL is not refreshing or is caching the url so it always thinks the door is closed. When I first built the script, I tested opening and closing a hundred times and it always seemed to update, but all of a sudden it seemed to stop….
Any problems with this code?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://XXXXXXXXXXXXXXX/digitalRead/7");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$manstatus = curl_exec($ch);
curl_close($ch);
My test output code is:
if ($manstatus = "D7 is ON")
{
echo 'Man door is closed!';
echo '
';
}
else if ($manstatus = "D7 is off")
{
echo 'Man door is open!';
echo '
';
}
It is saying closed EVERY TIME, even when I know the URL is saying open. I cant seem to figure out why all of a sudden this changed.
This is my first time using CURL, so feel free to tell me if I am doing this all wrong!
3 Replies
@Nibbler:
You need to use double equals (==) in your if tests. Single equals is used for assignment.
Made that change and a few others from feedback received from other members on IRC.
Solved!
$manstatus = filegetcontents("