加载中...
图片已保存到JSON文件,所有URL均为代理地址,可直接使用:
http://your-domain.com/random_api.php
获取随机图片(返回代理URL):
http://your-domain.com/random_api.php
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
format |
string | redirect | 返回格式:redirect (重定向), json (JSON数据), image (直接返回图片) |
category |
string | 空 | 按分类筛选,例如:default, 美女, 风景等 |
count |
integer | 1 | 返回图片数量(1-50),仅在format=json时有效 |
自动重定向到代理地址,可直接在img标签中使用
<img src="http://your-domain.com/random_api.php" alt="随机图片">
API直接返回图片二进制数据
<img src="http://your-domain.com/random_api.php?format=image" alt="随机图片">
返回的url字段已经是代理地址,可直接使用
http://your-domain.com/random_api.php?format=json
返回数据示例:
{
"id": 1,
"url": "http://your-domain.com/proxy_image.php?url=...",
"original_url": "https://cdn5.mmdb.cc/file/20260126/206371670568/00193261.jpg",
"alt": "诺诺子",
"source_url": "meirentu.club/pic/206371670568.html",
"category": "default",
"views": 10,
"created_at": "2025-01-20 10:30:00"
}
http://your-domain.com/random_api.php?category=美女&format=json
http://your-domain.com/random_api.php?format=json&count=5
// 使用 fetch 获取随机图片(返回的URL已经是代理地址)
fetch('http://your-domain.com/random_api.php?format=json')
.then(response => response.json())
.then(data => {
console.log('代理图片地址:', data.url);
console.log('原始图片地址:', data.original_url);
console.log('图片标题:', data.alt);
// 直接使用代理URL,无需担心防盗链
document.getElementById('myImg').src = data.url;
});
好消息!所有保存到图片库的URL都已自动转换为代理地址。
这意味着:
1. JSON返回的 url 字段可以直接使用
2. 无需手动处理防盗链问题
3. 支持在任何地方展示图片
4. 自动缓存机制,提升加载速度
-
加载中...