Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Example for http request needed
This thread has 4 replies. Displaying all posts.
Post 1 made on Thursday June 4, 2020 at 14:14
kapsreiter
Long Time Member
Joined:
Posts:
November 2006
48
hi

could someone help me and post the codes for this http request

it is working well from the browser

[Link: 10.0.0.13]


how could i switch it with the pronto


thx
tom

Last edited by Lyndel McGee (moderator) on June 12, 2020 18:53.
Post 2 made on Friday June 5, 2020 at 20:43
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,995
You don't want IR Codes, but rather you want ProntoScript.

You can do it with a raw socket or if you can locate the Philips ProntoScript Library for http, that will make it much simpler.

Here's an example using a raw socket.


[Link: remotecentral.com]


change the socket.onConnect function to this:

socket.onConnect = function()
{
socket.write("GET /relay/0?turn=toggle HTTP/1.0\r\n");
socket.write("Accept: */*\r\n");
socket.write("Host: 10.0.0.13\r\n");
socket.write("Connection: close\r\n");
socket.write("\r\n");
};


If you are not interested in any of the data coming back, you can safely ignore the onData assignment

socket.onData = function(data) {
// blah blah
}


and on the last section, ensure that instead of the IP address '192.168.1.99' that you use "10.0.0.13" and port 80.

if(socket.connected == false)
{
socket.connect('10.0.0.13', 80, 3000);
};


Note that I found this thread using a search for HTTP GET

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Saturday June 6, 2020 at 00:39
kapsreiter
Long Time Member
Joined:
Posts:
November 2006
48
thank ou


this is the complete working code

tom



var result = "";
var socket = new TCPSocket(false);
var t1,t2,t3,t4,t5;
var event1,event2;
var descrip1, descrip2;

socket.onConnect = function()
{
socket.write("GET /relay/0?turn=toggle HTTP/1.0\r\n");
socket.write("Accept: */*\r\n");
socket.write("Host: 10.0.0.13\r\n");
socket.write("Connection: close\r\n");
socket.write("\r\n");
};
socket.onData = function()
{
//result += socket.read(5000,1000);

t0 = result.indexOf("class=\"time\">", 0)+13;
t10 = result.indexOf("/span>",t0)-1;
tijd1 = result.substring(t0,t10);

t1 = result.indexOf("class=\"event\">", 0)+14;
t2 = result.indexOf("/span>",t1)-1;
event1 = result.substring(t1,t2);
CF.widget("channel1").label=event1;

t4 = result.indexOf("class=\"description\">", t2)+20;
t5 = result.indexOf("/span>",t4)-1;

t6 = result.indexOf("class=\"event\">", t5)+14;
t7 = result.indexOf("/span>",t6)-1;
event2 = result.substring(t6,t7);
CF.widget("channel2").label=event2;

};


socket.onClose = function()
{
};


socket.onIOError = function(e)
{
};


if(socket.connected == false)
{
socket.connect('10.0.0.13', 80, 3000);
};
Post 4 made on Saturday June 6, 2020 at 09:22
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,995
Tom,

It looks like you've commented out the socket.read statement in the onData function. As you are not reading any data, there is no need for the other lines inside that function and they may be causing errors, especially the ones that are using GUI.widget(). If you don't have these widgets defined on your page, then you are getting reference errors when the .label assignment is invoked.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 5 made on Friday June 12, 2020 at 18:53
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,995
If you just need to send a command via HTTP and don't care about the response data, see this post.

[Link: remotecentral.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse