Python 如何在Arduino IDE中向http请求添加头

Python 如何在Arduino IDE中向http请求添加头,python,arduino,arduino-ide,Python,Arduino,Arduino Ide,这是Arduino IDE中无法工作的代码(httpCode=-1): 我对ArduinoIDE编程非常陌生,我现在才开始使用python,所以我猜我的代码中可能有几个错误。有没有办法解决这个问题?您使用的addHeader看起来不错,但看起来您正试图通过HTTPS/TLS访问一个站点 Arduino HTTP客户端需要服务器使用的证书的指纹/哈希。由于Arduino设备的CPU和内存限制,这将取代通常的证书验证 您需要配置证书指纹以使获取工作。e、 g.定义服务器证书的指纹 const uin

这是Arduino IDE中无法工作的代码(httpCode=-1):


我对ArduinoIDE编程非常陌生,我现在才开始使用python,所以我猜我的代码中可能有几个错误。有没有办法解决这个问题?

您使用的
addHeader
看起来不错,但看起来您正试图通过HTTPS/TLS访问一个站点

Arduino HTTP客户端需要服务器使用的证书的指纹/哈希。由于Arduino设备的CPU和内存限制,这将取代通常的证书验证

您需要配置证书指纹以使
获取
工作。e、 g.定义服务器证书的指纹

const uint8_t fingerprint[20] = { 0xe4, 0x5b, 0x13, 0x58, 0xc0, 0x4c, 0x27, 0xcb, 0x84, 0x4e,
                                  0xe1, 0xbb, 0x28, 0xf5, 0x36, 0x7c, 0x4f, 0x06, 0xa0, 0x1a };
然后在调用
begin()

我尚未在此平台上订阅API,因此在尝试以下操作时得到了有效的403响应:

09:23:13.550 -> 403
09:23:13.550 -> {"message":"You are not subscribed to this API."}

如果HttpClient从url解析https,那么它应该会这样做
const uint8_t fingerprint[20] = { 0xe4, 0x5b, 0x13, 0x58, 0xc0, 0x4c, 0x27, 0xcb, 0x84, 0x4e,
                                  0xe1, 0xbb, 0x28, 0xf5, 0x36, 0x7c, 0x4f, 0x06, 0xa0, 0x1a };
    http.begin("https://api-football-v1.p.rapidapi.com/v2/fixtures/team/33/next/10",
               fingerprint);
09:23:13.550 -> 403
09:23:13.550 -> {"message":"You are not subscribed to this API."}