HTTP request through sketch
in
Programming Questions
•
2 years ago
Hi all,
I am trying to add a logfile to my online processing sketch so i can see how many people interact with my sketch in various ways. I wrote a little php script which appends a line to a text file, given some parameters in the url string, i.e.
mywebsite.com/sketch/log.php?a=5&b=7 writes 5 and 7 to a running text file. I'd like to pass the a and b parameters via my processing sketch by making an http request to that php page.
I copied and modified the code directly from Processing's http client documentation (
http://processing.org/learning/library/httpclient.html) into the following code below. The problem is that after running the script, it makes no change to the logfile, even though just typing the page into my browser does. Can anyone see what I am doing wrong? Thanks! Code follows....
import processing.net.*;
Client c;
void setup() {
c = new Client(this, "www.mywebsite.com", 80); // Connect to server on port 80
c.write("GET /sketch/log.php?a=5&b=7 HTTP/1.1\n"); // Use the HTTP "GET" command to ask for a Web page
}
1