首页 全部接口 API文档 文章 贡献者 友链 赞助 关于
登录/注册

图床v1(推荐用V2)

POST https://apis.whrx.chat/api/tc/index.php
由 AI 生成:以下文档内容根据提供的信息自动生成,仅供参考,具体实现以实际接口为准。

接口简介

图床v1接口用于接收图片文件上传,将图片转发到Telegram图床服务,并返回图片访问URL。适用于需要快速上传图片并获取URL的场景,无需鉴权。

请求说明

  • URL:https://api.xunjinlu.fun/api/tc/index.php
  • 方法:POST
  • 请求头:Accept: application/json

请求参数表

名称类型必填说明
imagefile要上传的图片文件,支持 JPG/PNG/GIF/WEBP 格式

返回字段表

字段名类型说明
codenumber状态码,200表示成功
msgstring状态信息
urlstring图片访问URL
timestring上传耗时
successboolean是否成功
api_infoobjectAPI信息

返回 JSON 示例

成功示例

{
"code": 200,
"msg": "success",
"url": "https://521.im/NGi9Qq4S.jpeg",
"time": "0.3s",
"success": true,
"api_info": {
"developer": "尋鯨錄",
"blog": "https://www.xunjinlu.fun",
"api_platform": "https://api.xunjinlu.fun"
}
}

失败示例

{
"code": 400,
"msg": "Invalid image format",
"url": "",
"time": "0.1s",
"success": false,
"api_info": {
"developer": "尋鯨錄",
"blog": "https://www.xunjinlu.fun",
"api_platform": "https://api.xunjinlu.fun"
}
}

错误与状态

  • 200: 成功
  • 400: 无效的请求参数
  • 500: 服务器内部错误

调用示例

直接访问

https://api.xunjinlu.fun/api/tc/index.php

cURL

curl -X POST "https://api.xunjinlu.fun/api/tc/index.php" -H "Content-Type: multipart/form-data" -F "image=@/path/to/image.jpg"

Python requests

import requests

url = "https://api.xunjinlu.fun/api/tc/index.php"
files = {'image': open('/path/to/image.jpg', 'rb')}
response = requests.post(url, files=files)
print(response.json())

PHP

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.xunjinlu.fun/api/tc/index.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['image' => '@/path/to/image.jpg']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print(json_decode($response, true));
?>

HTML

Uploaded Image