我试着用esp8266做一个时钟新闻天气滚动字幕。但是当我上传代码的时候,它出现了一个错误。你能帮帮我吗?以下是代码的一部分:(根据麻省理工学院许可证(版权所有2018 David Payne))
void PiHoleClient::getPiHoleData(String server, int port) {
errorMessage = "";
String response = "";
String apiGetData = "http://" + server + ":" + String(port) + "/admin/api.php?summary";
Serial.println("Sending: " + apiGetData);
HTTPClient http; //Object of class HTTPClient
http.begin(apiGetData);// get the result (**the error code**)
int httpCode = http.GET();
//Check the returning code
if (httpCode > 0) {
response = http.getString();
http.end(); //Close connection
if (httpCode != 200) {
// Bad Response Code
errorMessage = "Error response (" + String(httpCode) + "): " + response;
Serial.println(errorMessage);
return;
}错误:退出状态1调用“”HTTPClient::begin“”,使用属性error: obsolete API声明,请使用::begin(WiFiClient,url)“”
发布于 2021-05-26 18:14:25
您还需要从WiFiClient.h创建一个新的WiFiClient实例,并将其传递到begin:
#include <WiFiClient.h>
WiFiClient wifiClient;
void PiHoleClient::getPiHoleData(String server, int port) {
errorMessage = "";
String response = "";
String apiGetData = "http://" + server + ":" + String(port) + "/admin/api.php?summary";
Serial.println("Request: " + apiGetData);
HTTPClient http; //Object of class HTTPClient
http.begin(wifiClient, apiGetData);// get the result (**the error code**)
int httpCode = http.GET();
//Check the returning code
if (httpCode > 0) {
response = http.getString();
http.end(); //Close connection
if (httpCode != 200) {
// Bad Response Code
errorMessage = "Error response (" + String(httpCode) + "): " + response;
Serial.println(errorMessage);
return;
}发布于 2021-07-17 23:00:17
我看过这篇文章并检查过这篇文章,本周早些时候我将esp8266核心更新到了v3.0.0,还发现marquee scroller无法编译,并给出了相同的错误,我重新安装了v2.7.4,它是第一次编译。
https://www.gitmemory.com/issue/Qrome/marquee-scroller/186/846463005
https://stackoverflow.com/questions/67702822
复制相似问题