完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
为了 ISP 的安全,我无法直接连接到数据库服务器,所以我需要通过 PHP 文件使用 API 发送数据,PHP 文件又将数据存储到数据库服务器中。
PHP 文件通过 html 形式或通过 python 代码工作正常,所以我很确定我遇到的问题是我的代码。 执行代码时收到的错误是“无法连接”。我只能假设这是一个 SSL 连接问题,因为 ISP 网络服务器需要安全连接。 我怎么做? tiA 代码:全选const char* dbServerName = "https://www.mydomain.com/post_data.php"; void db_send() { //Check WiFi connection status if (WiFi.status() == WL_CONNECTED) { HTTPClient http; // Your Domain name with URL path or IP address with path http.begin(dbServerName); // Specify content-type header http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //concat data to be sent String httpRequestData = "api_key=" + apiKeyValue + "&temp=" + String(t) + "&humidity=" + String(h) + "&board=" + board + ""; //let's see what is being sent Serial.print("httpRequestData: "); Serial.println(httpRequestData); // Send HTTP POST request int httpResponseCode = http.POST(httpRequestData); if (httpResponseCode > 0) { Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); } else { Serial.print("Error code: "); Serial.println(httpResponseCode); // if -1 connection failed!! } // Free resources http.end(); } else { Serial.println("WiFi Disconnected"); } } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
231个成员聚集在这个小组
加入小组565 浏览 1 评论
2679 浏览 2 评论
为blufi_device设置自定义名称,但是无法修改,为什么?
495浏览 4评论
请问ESP32-S2-WROOM怎么获得ESP32-S2外接FLASH的唯一序列号?
274浏览 3评论
1088浏览 3评论
ESP-Jumpstart例程中第5个工程:5_cloud连接报错是哪里的问题?
283浏览 2评论
用AT+CIPSNTPCFG=1,8,\"cn.ntp.org.cn\",\"ntp.sjtu.edu.cn\"更新不了时间怎么处理?
770浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-5-13 19:28 , Processed in 1.018250 second(s), Total 72, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191