PHP必应每日壁纸图片API接口源码
<?php
$str = file_get_contents('https://cn.bing.com/HPImageArchive.aspx?idx=0&n=1'); // 从bing获取数据
if(preg_match('/<url>(.*?)<\/url>/', $str, $matches)) { // 正则匹配抓取图片url
$imgurl = 'https://cn.bing.com'.$matches[1];
} else { // 如果由于某些原因,没抓取到图片地址
$imgurl = 'http://img.infinitynewtab.com/InfinityWallpaper/2_14.jpg'; // 使用默认的图像(默认图像链接可修改为自己的)
}
header("Location: {$imgurl}"); // 跳转至目标图像
?>
新建PHP文件,复制粘贴以上代码,上传网站目录直接访问即可。
阅读剩余
版权声明:
作者:知道君
链接:https://blog.ccswust.org/19194.html
文章版权归作者所有,未经允许请勿转载。
THE END