Files
EasyImages2.0/docs/公共查询.md
2023-02-06 01:40:22 +08:00

40 lines
1.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

可用让网站提供一些可用对外展示的数据
- 首先在`图片安全`开启开放数据
- 根据需要选择要对外展示的数据
![](images/QQ截图20220222162359.png)
现在就可以直接访问指定参数的链接获得数据了。
例如获得已经建立的文件夹http://127.0.0.1/api/public.php?show=dir
![](images/QQ截图20220222162603.png)
jQuery调用演示代码
```html
<span id="public"></span>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"></script>
<script>
$.ajax({ //创建ajax对象
url: "http://127.0.0.1/api/public.php",
data: { //发送到服务器的数据
show: "file",
        },
success: function(resp) { //服务器响应成功的数据
//resp服务端响应过来的数据
$("#public").text(resp); //渲染到浏览器上
        }
    });
</script>
```
或者
```html
<p>今日上传<span id="public_today">loading...</span>张图片</p>
<p>本站已托管<span id="public_file">loading...</span>张图片</p>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"></script>
<script>
$("#public_today").load("http://127.0.0.1/api/public.php?show=today");$("#public_file").load("http://127.0.0.1/api/public.php?show=file");
</script>
```