本接口由接口盒子提供文本存储API提供免费的文本存储服务,支持存储1000条文本记录(每条记录最大5000字符)。适用于公告存储、日志管理、配置信息存储等场景,支持修改和读取操作。
参数 | 必填 | 说明 |
|---|---|---|
id | 是 | 用户中心数字ID |
key | 是 | 用户中心通讯秘钥 |
type | 是 | 1=修改记录,2=读取记录 |
numid | 是 | 记录ID(1-1000) |
words | 否* | 记录内容(type=1时必填) |
title | 否 | 记录标题(type=1时可选) |
注:示例中的公共ID/KEY有频次限制,请注册获取独享ID/KEY
bash复制https://cn.apihz.cn/api/cunchu/textcc.php?
id=88888888&
key=88888888&
type=1&
numid=1&
words=这是测试内容&
title=这是测试标题PHP实现:
php复制<?php
$url = 'https://cn.apihz.cn/api/cunchu/textcc.php';
$data = [
'id' => '88888888',
'key' => '88888888',
'type' => 2, // 读取记录
'numid' => 1
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// 处理返回结果
$result = json_decode($response, true);
if ($result['code'] == 200) {
echo "标题:" . $result['title'] . "\n";
echo "内容:" . $result['words'];
} else {
echo "错误:" . $result['msg'];
}
?>Python实现:
python运行复制import requests
# 修改记录
def update_text():
url = "https://cn.apihz.cn/api/cunchu/textcc.php"
params = {
"id": "88888888",
"key": "88888888",
"type": 1, # 修改记录
"numid": 1,
"words": "新的公告内容",
"title": "系统公告"
}
response = requests.post(url, data=params)
return response.json()
# 读取记录
def get_text(record_id):
url = "https://cn.apihz.cn/api/cunchu/textcc.php"
params = {
"id": "88888888",
"key": "88888888",
"type": 2, # 读取记录
"numid": record_id
}
response = requests.get(url, params=params)
return response.json()
# 使用示例
if __name__ == "__main__":
# 更新记录
update_result = update_text()
print("更新结果:", update_result)
# 读取记录
record = get_text(1)
if record['code'] == 200:
print(f"记录内容: {record['words']}")
else:
print(f"错误: {record['msg']}")成功响应:
json复制{
"code": 200,
"jiluid": 1,
"time": "2024-04-20 17:44:16",
"msg": "修改成功",
"words": "存储的内容",
"title": "标题文本"
}错误响应:
json复制{
"code": 400,
"msg": "通讯秘钥错误"
}原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。