-->
Page 3 of 3

Re: Example: http get a page?

PostPosted: Thu Oct 22, 2015 12:09 pm
by Erni
Thanks kolban,

I think I am beginning to understand this new way of thinking (I am used to Arduinos procedural way of doing things)
So do you think this is the way to do it ?:

Code: Select allESP8266WiFi.init();

var hostname="www.eecs.mit.edu";

ESP8266WiFi.getHostByName(hostname, function(ipAddress){

var http = require("http");

  http.get({host: ESP8266WiFi.getAddressAsString(ipAddress), port: 80, path: "/"},
    function(response) {
    print("get callback!");
    response.on('data', function(data) {
      print(data);
    });
    response.on('close', function() {
       print("The response connection closed");
    });
});
 
});

Re: Example: http get a page?

PostPosted: Thu Oct 22, 2015 3:06 pm
by kolban
Howdy Erni,
Yes sir. That looks perfect to my eyes.

Re: Example: http get a page?

PostPosted: Mon Nov 16, 2015 1:13 am
by gonsays
Hello,

This example is great! Can I find a certain string on the data variable?

I would like to do a HTTP GET to a php file, can I identify if a certain string (example: "State1") is on the php file?