Creating a PHP?

I have been trying to create a php to work with endpoints so i can dim my movie room lights. But i haven’t been able to figure it out below is what i have so far. Any help would be greatly appreciated


Have you seen this tutorial?

It links to the smartapp code here SmartThings API Endpoint Example · GitHub

and the corresponding php code here SmartThings .php example authenticating and controlling SmartThings API endpoints · GitHub

It looks like you are using that php code from the link. Do you have it on a web server running php? If so, what happens when you bring up the page?

If it’s working, once you get through the authorization, you’ll need to bookmark the URL. It’s been a while since I set one up, but I know in some cases, it didn’t automatically forward when going from one step to the next

yeah i am using the example php code i read through the tutorial but still didn’t quite understand it. I didnt know i need to create a web server for this to work i just keep saving the file as an html and trying to open it in ie.Thank you for the help now i will figure out how to set up a web server.

PHP is sever side code that the web server acts on and then sends back HTML code back to the browser. In the case of the ST code, the web server makes the calls to ST found in the PHP code and presents back to the user the HTML representation

Here’s a quick tutorial on setting up a basic xampp web server

What are you ultimately trying to do with the HTTP end points? Do you want to call those HTTP end points from a computer, web server, phone, etc?

I am trying to set my cree connected buld to dim then i press the play button on xbmc and then go to full brightness when i hit stop. i found the tutorial for to set it up i was just very confused on the php part.

Okay i got the webserver setup on my pc now i just need some help with what to put in the following boxes i put the client id from the endpoint app in here or does something else go in here.

2.same question as above. the url how i access it from my c:\ or would it be the address that i use to access the .php file externally?

1 & 2 - yes they come from the smartapp

3 looks like it would be http://localhost/Apps/test2.php

when i tried that i get the error parse error: syntax error, unexpected ‘b71404e’ (T_String) in C:\xampp\htdocs\Apps\test2.php on line 3.

to run that php do i just navigate to the localhost\Apps folder than double click on test2.php?

Did you put the client and secret in quotes within the PHP file?

$client = "437ead40-c08d-41f9-a91e-c6c10144d1da"; //replace with your Client ID
$secret = "e41192c9-5cc3-4008-a847-b9575ab624dc"; //replace with your Client Secret

no i will go back and try that out

okay i made the change and now i am getting OAuth2 Error
error=“invaild_client”. error_description=“Bad Client credentials”

the client id i got was from here

Now after i pick all the lights i want to see the url for i get error requesting access token…

For what it’s worth, the web services documentation includes a tutorial to create a web services SmartApp. It doesn’t use PHP, but the principles are the same.

This documentation will receive updates for any changes, so may be a bit more future-proof than the older tutorial posted on the forums.