Endpoint problem


(Chrisb) #1

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?


(Chrisb) #2

Bump… anyone else running into this problem?


(John Essey) #3

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 :\


(Gilbert Chan) #4

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.


(Andrew Urman) #5

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.


(Gilbert Chan) #6

@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.


(Andrew Urman) #7

@thegibertchan

oh stop it you!


(Chrisb) #8

@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?


(Andrew Urman) #9

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.


(Gilbert Chan) #10

Any updates?

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


(Chrisb) #11

@urman

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

Thx.


(Andrew Urman) #12

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


(Chrisb) #13

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.


(Chrisb) #14

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?


(Andrew Urman) #15

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";


(Roy Dufek) #16

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:


(Roy Dufek) #17

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


(Morgan) #18

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


(John Essey) #19

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


(Wheeler) #20

Example Endpoint App is working again- thanks!