zoukankan      html  css  js  c++  java
  • Arduino ESP8266 发送HTTP请求 获取苏宁服务器时间

    参考:发送HTTP请求

    参考:获取时间

    #include <ESP8266WiFi.h>
    
    #include <ESP8266HTTPClient.h>
    
    
    //在这里输入你家的WiFi名字和密码
    const char* ssid     = "hg2020"; 
    
    const char* password = "12345678";   
    
    HTTPClient http;
    
    String GetUrl;
    
    String response;
    
    void setup() {
    
      // 连接到你家的WiFi
    
      delay(3000);
    
      Serial.begin(115200);
    
      WiFi.mode(WIFI_STA);
    
      WiFi.begin(ssid, password);
    
      while (WiFi.status() != WL_CONNECTED) {
    
        delay(500);
    
        Serial.print(".");
    
      }
    
    
      Serial.println("");
    
      Serial.println("WiFi connected");
    
      Serial.println("IP address: ");
    
      Serial.println(WiFi.localIP());
    
    
      // 连接苏宁网站的授时网页
    
      GetUrl = "http://quan.suning.com/getSysTime.do";
    
      http.setTimeout(5000);
    
      http.begin(GetUrl);
    
    
    }
    
    
    void loop() {
    
      // 从网站获得网页内容
    
      int httpCode = http.GET();
    
      if (httpCode > 0) {
    
          Serial.printf("[HTTP] GET... code: %d
    ", httpCode);
    
          if (httpCode == HTTP_CODE_OK) {
    
            //读取响应内容
    
            response = http.getString();
     
            Serial.println(response);
    
          }
    
      } else {
    
          Serial.printf("[HTTP] GET... failed, error: %s
    ", http.errorToString(httpCode).c_str());
    
      }
    
      http.end();
    
      delay(3000);
    
    }
    

      

  • 相关阅读:
    这之后的事。。。
    POJ
    POJ
    博客园的装饰
    高斯消元
    逆序数技巧
    各种小的 dp (精)
    最大区间和变形
    树dp 统计异或值
    dp
  • 原文地址:https://www.cnblogs.com/dengziqi/p/14196993.html
Copyright © 2011-2022 走看看