call to HTTPClient::begin declared with attribute error: obsolete API, use ::begin(WiFiClient, url)

这篇博客介绍了在遇到8266库版本不一致导致的错误时,如何修改HTTPClient的使用方式以适应新的库。通过引入WiFiClient并将其作为参数传递给HTTPClient的begin方法,可以解决这个问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

应该是8266自带库版本不一样,此处需要改一下用法:


WiFiClient client; //新添加
HTTPClient httpClient;
httpClient.begin(client,url); 

即可。

### 配置 Ubuntu 24.04 的官方及第三方镜像源 #### 官方镜像源配置 对于 Ubuntu 系统,其官方镜像源可以通过编辑 `/etc/apt/sources.list` 文件来完成配置。以下是针对 Ubuntu 24.04 的具体操作: 1. 打开终端并备份当前的 `sources.list` 文件: ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 2. 编辑 `sources.list` 文件: ```bash sudo nano /etc/apt/sources.list ``` 3. 将以下内容粘贴到文件中(适用于 Ubuntu 24.04 LTS)[^1]: ``` deb http://archive.ubuntu.com/ubuntu/ twentyfour main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ twentyfour main restricted universe multiverse deb http://security.ubuntu.com/ubuntu/ twentyfour-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu/ twentyfour-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ twentyfour-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ twentyfour-updates main restricted universe multiverse ``` 4. 更新软件包索引: ```bash sudo apt update ``` #### 第三方镜像源配置 为了提高下载速度或访问特定资源,可以使用国内的第三方镜像源。以下是常见的几种配置方式。 ##### 使用阿里云镜像源 1. 替换 `sources.list` 中的内容为阿里云镜像地址: ``` deb https://mirrors.aliyun.com/ubuntu/ twentyfour main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ twentyfour main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ twentyfour-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ twentyfour-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ twentyfour-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ twentyfour-updates main restricted universe multiverse ``` 2. 如果遇到密钥问题,可执行以下命令导入所需密钥[^2]: ```bash sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 ``` 3. 再次更新软件包索引: ```bash sudo apt update ``` ##### 使用清华大学镜像源 同样地,也可以替换为清华大学开源软件镜像站中的地址: ``` deb https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour main restricted universe multiverse deb-src https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour main restricted universe multiverse deb https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour-security main restricted universe multiverse deb-src https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour-security main restricted universe multiverse deb https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour-updates main restricted universe multiverse deb-src https://mirror.tuna.tsinghua.edu.cn/ubuntu/ twentyfour-updates main restricted universe multiverse ``` 完成后记得运行 `sudo apt update` 命令刷新缓存。 ---
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式点灯大师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值