- 自动跳转到每日一图(当天) https://api.kdcc.cn/img/
- 指定日期跳转 https://api.kdcc.cn/img/?day=2020/06/06 (按格式修改红色部分日期,指定2020/04/26之后的日期)
- 随机跳转图片 https://api.kdcc.cn/img/rand.php
- 直接跳转到每日一图(必应服务器,速度快) https://api.kdcc.cn/img/jump.php
调用方式
<img src=”https://api.kdcc.cn/img/” />
PHP核心代码,其他的根据自己的需求修改即可
<?php
$str = file_get_contents('https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1'); //读取必应api
$str = json_decode($str,true); //接受JSON 编码的字符串并且把它转换为 PHP变量
$imgurl = 'https://cn.bing.com'.$str['images'][0]['url']; //获取图片url
header("Location: {$imgurl}"); // 跳转至目标图像
?>