Author |
|
ibscas Groupie
Joined: October 18 2008 Location: United States
Online Status: Offline Posts: 46
|
Posted: October 28 2008 at 20:21 | IP Logged
|
|
|
I've been trying for 9 hours to get data out of the web server and just have one MAJOR roadblock. Is there ANY way to get data out of the web server WITHOUT all the other junk?
For instance, when you run a /ph-cgi/formula, you get a whole page of stuff, including another form to run another formula. I ONLY want the result, nothing else. How can I do that?
I've played with regular expressions and all sorts of stuff, the only place the data even shows up is in a full on HTML page that says:
"The result of your previous formula: ph_sql(1,"Select distinct location from devicestatus order by location")
is:....."
I just want the data after the 'is:' and nothing else, any way to do this?
|
Back to Top |
|
|
JaredM Newbie
Joined: November 04 2007
Online Status: Offline Posts: 36
|
Posted: October 28 2008 at 23:10 | IP Logged
|
|
|
One way to do it is create a psp page in the Program Files\powerhome\web directory that contains something like this:
<html>
<body>
<%
//your PH functions go here
%>
</body>
</html>
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 29 2008 at 07:39 | IP Logged
|
|
|
What are you doing to get that?
I think a solution may be to submit a form with a post to /ph-cgi/evalformula. See my example in your thread, "Fetching Data from Web Server".
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 29 2008 at 07:50 | IP Logged
|
|
|
Ouch. I just tried your formula on the web Formula page, but for an XML-format data return, and it crashed PH!
Of course, that means that the web server port was not freed, and I now need to restart.
|
Back to Top |
|
|
ibscas Groupie
Joined: October 18 2008 Location: United States
Online Status: Offline Posts: 46
|
Posted: October 29 2008 at 09:41 | IP Logged
|
|
|
JaredM wrote:
One way to do it is create a psp page in the Program Files\powerhome\web directory that contains something like this:
<html>
<body>
<%
//your PH functions go here
%>
</body>
</html>
|
|
|
I did consider that, but since PH reads the <% ph??? %> command when it parses the file, it would be impossible for that to be dynamic and I would have to devise a way for my web pages to dynamically write into a PSP file the routine I wanted to run.
|
Back to Top |
|
|
ibscas Groupie
Joined: October 18 2008 Location: United States
Online Status: Offline Posts: 46
|
Posted: October 29 2008 at 09:44 | IP Logged
|
|
|
TonyNo wrote:
What are you doing to get that?
I think a solution may be to submit a form with a post to /ph-cgi/evalformula. See my example in your thread, "Fetching Data from Web Server". |
|
|
That leads me into the exact same issue, having to parse a web page. It would be easier if the web page that was returned had a <DIV ID="Results"> or something like that around the portion after "is:", that way I can just pull the page and say "include the tag "Results".
|
Back to Top |
|
|
raven77 Groupie
Joined: January 02 2007 Location: United States
Online Status: Offline Posts: 44
|
Posted: October 29 2008 at 12:59 | IP Logged
|
|
|
Are you trying to update just the status of your device on the webpage and no the whole page? I have been trying to do that for a while, good luck!
The only way I found to do it so far is with Ajax and .asp pages. I actually got it to work but only with one device, I didn't find a way yet to put multiple devices on one asp page and give them ID's and just put the ID's on the PSP page for each device.
I am FAR from an expert on this, so I hope someone can figure out what I am trying to say and help me!
LOL
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 29 2008 at 13:28 | IP Logged
|
|
|
At this point, I think it would be helpful to see your code or the page. That may provide the info we need to assist.
Also, this PSP file may hold what you need.
|
Back to Top |
|
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: October 29 2008 at 14:08 | IP Logged
|
|
|
So I just have a generic psp page that grabs the html parameter and tries to execute it as a PH function.
To run a macro I just hit the following URL:
Code:
run.psp?run=ph_macroparm('MACRO_NAME', '','',0,0,0) |
|
|
The run.psp page looks like:
Code:
<html><body>
<% ph_formula(ph_getwebparm("run")) %>
</body></html> |
|
|
The body of this page will contain whatever was in LOCAL1 when the macro ended
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 29 2008 at 15:42 | IP Logged
|
|
|
Craig,
For the SQL you provided in the first post, you should be able to use the following code to achieve what you want:
Code:
<html>
<body>
<%ph_sql(0,"Select distinct location || '<br>~r~n' from devicestatus order by location")%>
</body>
</html>
|
|
|
Just copy and paste the above code into a file names "test.psp" and save the file into the web directory. Access it using the following URL: http://127.0.0.1/test.psp
I think that will supply what you're looking for.
Dave.
|
Back to Top |
|
|
ibscas Groupie
Joined: October 18 2008 Location: United States
Online Status: Offline Posts: 46
|
Posted: October 29 2008 at 18:09 | IP Logged
|
|
|
dhoward wrote:
Craig,
For the SQL you provided in the first post, you should be able to use the following code to achieve what you want:
Code:
<html>
<body>
<%ph_sql(0,"Select distinct location || '<br>~r~n' from devicestatus order by location")%>
</body>
</html>
|
|
|
I think that will supply what you're looking for.
Dave.
|
|
|
In terms of better data, yes, but in terms of it being completely static, not as much. I have a page right now that DYNAMICALLY runs the PH commands and returns the results, what I was wanting it to do was be able to fetch those results (i.e., running a formula) and return those to me without any other HTML data on the page. Your idea works great but requires that I have the PH command embedded in the code of a page so that when you parse it you get the results, presto. I'm, instead, running the 'formula' part of the web site so I can just ASK for results for ANY command, rather than have a static entry.
All of this being said, I spent another five hours or so and came up with a slick method get my results, I just have to weed out all that extra HTML for the ACTUAL data that I want.
Since there might be some wondering: I've developed an AJAX site for PH using just a single page. Everything this 'program' does is from a single page with about 50 lines of html/coding (although the 'program' in its entirety is more like 5000 lines). The end result of this is for a batch of touchscreens coming in but more than anything else I developed it for an iPod Touch/iPhone interface (very cool looking I think) because I have five more of those coming in as remote controls/home automation units.
At this point, I have a half decent alpha, my plan is to get this puppy running fully and share this out to all the folks here who might desire a more interactive web interface than what is currently provided with PH (no offense Dave!).
Edited by ibscas - October 29 2008 at 18:10
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 29 2008 at 18:29 | IP Logged
|
|
|
Craig,
Definately interested in seeing what you come up with.
Concerning the code above though, it shouldnt be static. The SQL should be dynamically executed with new results returned everytime the test.psp page is requested. However, I may not fully understand what you're trying to accomplish.
It sounds as if you'd like to have a /ph-cgi/ function where you can evaluate a formula and have the result returned without any HTML wrapping it. Something like http://127.0.0.1/ph-cgi/eval?formula=ph_sql(0,"select distinct location from devicestatus") and the result is JUST the output of the ph_sql function without any HTML. This would be essentially the same as what Tony (not No) has achieved with his run.psp posted above. Is this correct? If so and there is value in this, I can easily add this into the upcoming version pretty quickly.
Dave.
|
Back to Top |
|
|
raven77 Groupie
Joined: January 02 2007 Location: United States
Online Status: Offline Posts: 44
|
Posted: October 29 2008 at 21:20 | IP Logged
|
|
|
Any way to use ph_getwebparm ( s ) to get device status to a webpage dynamically?
|
Back to Top |
|
|