Endpoint problem

Anyone else having problem using Endpoints right now? When I try to hit any of them nothing is happening.

I went to the example php file to see if I could hit them from there and I get the log in, the authorize screen, and then I get an error after hitting authorize:

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

Any ideas?

Bump… anyone else running into this problem?

I’m having the same problem as well. I noticed it Friday when you posted originally. Not much help, but it’s not you at least :\

Same here… I tried sending a message to support, no luck yet.

Seems like someone modified the PHP code; only ST can resolve it internally, unless someone wants to republish the PHP on their own servers.

Hey guys we’re looking into the issue. Appears to be around HTTP/HTTPS. I’ll have a clearer update sometime tomorrow.

@thegibertchan and others who have submitted tickets I’ll update you there as well when I have more.

@urman, awesome.

Glad to see that you guys are actively on these issues. This is where I think ST is going to excel and ultimately create the best HA platform.

@thegibertchan

oh stop it you!

@urman, my guess it that it might be related to the api login page.

I know I had some bookmarks that would take me right to the MyDevices screen. But if I wasn’t logged in it would just bounce me to the login screen. Now I get an error saying page can’t be found. The link seems to be pointed to a wrong spot.

Did some of the api pages get reorganized?

We found the problem. Security concerns forced us to only accept HTTPS. We’ll be posting more about it tomorrow along with how to fix it. I’ll be on office hours as well to talk about it.

So basically moving everything to HTTPS should fix the problem.

Any updates?

Also, can we modify the endpoint example to switch modes?

@urman

Did this get fixed? I’d like to start playing around with UBI now that I got it (woot!).

Thx.

hey all. I’ll be writing something up for tomorrows developer email, but the only change is you need to use HTTPS when interacting with anything to graph.api.smartthings.com.

So any commands or requests you’re sending in just need to be HTTPS

Thanks @urman.

My problem right now is that the sample php linked from here: http://build.smartthings.com/labs/ (See the link: Install the example endpoint SmartApp) is still giving me the error message shown in the first post so I can’t seem to successfully get to the point of seeing what the endpoint addresses should be.

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 (23.23.13.21/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?

Yup thats the issue. We’re going to send out a developer email about it. I haven’t had time yet to swap out the examples. So just change:

$switchUrl = "http://graph.api.smartthings.com".$v['url']."/switches";

to

$switchUrl = "https://graph.api.smartthings.com".$v['url']."/switches";

Wrote a long response. But I don’t what I’m talking about lol- let us know when you swap the php files! :slight_smile:

Ok, not sure if you replaced the line in the PHP page or not, but now I’m getting a different page now when I authorize:

Error
500: Internal Server Error
URI
/oauth/authorize
Reference Id
6e460689-1edc-4cac-967b-2463ae710c51
Date
Thu Mar 27 18:13:50 UTC 2014
Class
java.lang.NullPointerException
Message
Cannot get property ‘scope’ on null object

Where can you download the .php file? What is the link for that?

@thrash99er… see from: http://build.smartthings.com/blog/tutorial-creating-a-custom-rest-smartapp-endpoint/#comments

Example Endpoint App is working again- thanks!