# LinuxAPI
**Repository Path**: tichuan-cloud/LinuxAPI
## Basic Information
- **Project Name**: LinuxAPI
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2025-06-14
- **Last Updated**: 2025-08-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
获取天气和时间的相关API
# 获取天气与时间
[](https://github.com/用户名/项目名)
[](https://opensource.org/licenses/MIT)
[](https://github.com/用户名/项目名/actions)
提供了两份程序来实现时间获取和天气获取。
## 使用
### 1. 天气获取
- linux系统需要联网
- 需要自行到高德地图API处申请密钥和adcode并在程序(weather.c)中修改
```c
char * http_str = "GET https://restapi.amap.com/v3/weather/weatherInfo?key=你的密钥&city=城市的adcode编码 HTTP/1.1\r\nHost:restapi.amap.com\r\n\r\n";
```
- 文件修改好后,使用gcc编译运行即可。
### 2. 时间获取
- linux系统需要联网
- 需要自行到阿里云云市场时间API处申请APPCODE和城市名称的URL编码并在程序(time_http.c)中修改
```c
char * http_str = "GET https://timezone.market.alicloudapi.com/timezone?city=%E5%8D%97%E6%98%8C HTTP/1.1\r\nHost:timezone.market.alicloudapi.com\r\nAuthorization:APPCODE 你的APPCODE\r\n\r\n";
```
## 核心
- 1.基于TCP通信的客户端程序连接http服务器,上传http报文。
- 2.阿里云云市场时间API接口
```c
https://market.aliyun.com/apimarket/detail/cmapi00065085?spm=5176.730005.result.2.5e15338ea6vmXV&innerSource=search
```
- 3.高德天气API接口
```c
https://lbs.amap.com/api/webservice/guide/api/weatherinfo
```