INFOBoard/lib/utils/utils.cpp

55 lines
1.4 KiB
C++

#ifdef __UTILS__
#include <utils.h>
#endif
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
String ver("v0.0.1");
String localIP("Unconnected");
String NAME = "仙女小可"; //改成自己的名字
static String UID = "450115492"; //改成自己的UID
static String followerUrl = "http://api.bilibili.com/x/relation/stat?vmid=" + UID; // 粉丝数
static String viewAndLikesUrl = "http://api.bilibili.com/x/space/upstat?mid=" + UID; // 播放数、点赞数
long follower_hist = 0; // 历史粉丝数
long follower = 0; // 粉丝数
long view = 0; // 播放数
long likes = 0; // 获赞数
static DynamicJsonDocument jsonBuffer(256);
void getFollower(String url) {
HTTPClient http;
http.begin(url);
int res_code = http.GET();
if( res_code == 200 ) {
String res = http.getString();
DeserializationError error = deserializeJson(jsonBuffer, res);
if( error ) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
follower_hist = follower;
follower = jsonBuffer["data"]["follower"];
} else {
Serial.printf("[HTTP] GET... failed, error: %d\n", res_code);
}
http.end();
}
void getViewAndLikes(String url) {
}