I hate to be a squeaky wheel here, but I’m wondering if someone could check on this? @megapixel @urman
I’ve tried to download the php file and set it up on a personal server but unfortunately it appears to be beyond my skills. I can’t seem to get it to play right.
I’d previously used the php file on SmartThings server without issue (126.96.36.199/exampleOauth.php) but now I keep getting the error code:
Warning: Invalid argument supplied for foreach() in /var/www/exampleOauth.php on line 86 Warning: Invalid argument supplied for foreach() in /var/www/exampleOauth.php on line 119
I’m assuming the the php file located at the address above is the same as the one that I can download. If so, it appears that the problem is caused when the site tries to pull in the switches or locks that were authorized. Here’s the code in question:
foreach($respData as $i => $switch)
$label = $switch['label'] != "" ? $switch['label'] : "Unlabeled Switch";
print " <h3>$label</h3>";
The error is saying the argument supplied in the foreach() is bad, so looking at that line, what is ‘$respData’?
$respData = json_decode($resp,true);
Okay, but then what’s $resp?
$resp = curl_exec($ch);
Fine, so what’s $ch?
$ch = curl_init($switchUrl);
Ugh… okay, great, the what’s $switchUrl?
$switchUrl = “http://graph.api.smartthings.com”.$v[‘url’]."/switches";
Okay… here might be the problem! Urman said above that we need to change these to https. Is it possible that it’s running into an issue here because this is trying to point to just http?