Launch actions from a PHP script

Posted on
Mon Aug 27, 2012 12:25 am
Juju offline
User avatar
Posts: 108
Joined: Aug 31, 2011
Location: Toulouse - FRANCE

Launch actions from a PHP script

Hello,

I'm trying to launch some actions from a PHP script. The web server running the PHP script is on the same Mac than Indigo.
This is my PHP code :
Code: Select all
$content = file_get_contents("http://login:password@localhost:8176/actions/Reboot%20Device?_method=execute");


I have an error in the Indigo logs : access denied "http://localhost:8176/actions/Reboot Device" from login @ 127.0.0.1
The same URL works if I put it directly in a browser.

What is wrong ?

Posted on
Mon Aug 27, 2012 10:13 am
jay (support) offline
Site Admin
User avatar
Posts: 18243
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Launch actions from a PHP script

What OS version? If it's Mountain Lion (or perhaps even Lion) it's probably a sandboxing issue. The browser is probably running from the same user account as the Indigo Server but the PHP script probably isn't. With increased security comes increased headaches... ;)

You might try putting in the external IP address rather than the loopback address to see if that makes a difference...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Aug 27, 2012 11:47 am
Juju offline
User avatar
Posts: 108
Joined: Aug 31, 2011
Location: Toulouse - FRANCE

Re: Launch actions from a PHP script

Thanks Jay.
I have Mountain Lion. Same result with the external IP or domain name.

Posted on
Mon Aug 27, 2012 3:30 pm
matt (support) offline
Site Admin
User avatar
Posts: 21421
Joined: Jan 27, 2003
Location: Texas

Re: Launch actions from a PHP script

Based on the error in the Event Log, I don't think it is a firewall/sandbox problem.

Presuming you are sure the username/password is correct, it looks like file_get_contents() isn't handling the authentication correctly. I suspect it doesn't handle HTTP Digest Authentication correctly. You might have to use curl or something else. Unfortunately, I'm not that familiar with PHP.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest