首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >文本存储免费API接口教程

文本存储免费API接口教程

原创
作者头像
用户9840656
发布2025-07-13 13:07:50
发布2025-07-13 13:07:50
6840
举报
接口简介

本接口由接口盒子提供文本存储API提供免费的文本存储服务,支持存储1000条文本记录(每条记录最大5000字符)。适用于公告存储、日志管理、配置信息存储等场景,支持修改和读取操作。

基本参数

参数

必填

说明

id

用户中心数字ID

key

用户中心通讯秘钥

type

1=修改记录,2=读取记录

numid

记录ID(1-1000)

words

否*

记录内容(type=1时必填)

title

记录标题(type=1时可选)

注:示例中的公共ID/KEY有频次限制,请注册获取独享ID/KEY


调用示例

1. GET请求示例
代码语言:javascript
复制
bash复制https://cn.apihz.cn/api/cunchu/textcc.php?
  id=88888888&
  key=88888888&
  type=1&
  numid=1&
  words=这是测试内容&
  title=这是测试标题
2. POST请求示例

PHP实现​:

代码语言:javascript
复制
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实现​:

代码语言:javascript
复制
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']}")

返回结果说明

成功响应​:

代码语言:javascript
复制
json复制{
  "code": 200,
  "jiluid": 1,
  "time": "2024-04-20 17:44:16",
  "msg": "修改成功",
  "words": "存储的内容",
  "title": "标题文本"
}

错误响应​:

代码语言:javascript
复制
json复制{
  "code": 400,
  "msg": "通讯秘钥错误"
}

使用场景

  1. 公告系统​:存储网站公告内容
  2. 配置管理​:保存系统配置参数
  3. 日志存储​:记录关键操作日志
  4. 临时数据​:存储需要跨会话共享的数据

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

目录
  • 接口简介
  • 基本参数
  • 调用示例
    • 1. GET请求示例
    • 2. POST请求示例
  • 返回结果说明
  • 使用场景
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档