必应图片调取接口

   bing图片每日更新,对于这一点感觉挺不错的,如果能够把bing每日图片作为博客背景是不是很不错呢?

 附上api代码:

    

<?php
if($_GET[‘idx‘]==null){
$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
}

$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.$_GET['idx'].'&n=1');
if(preg_match("/<url>(.+?)</url>/ies",$str,$matches)){
$imgurl='http://cn.bing.com'.$matches[1];
}
if($imgurl){
header('Content-Type: image/JPEG');
@ob_end_clean();
@readfile($imgurl);
@flush(); @ob_flush();
exit();
}else{
exit('error');
}
?>

  接口地址演示:http://www.sdfymj.com/api/biying.php

原文地址:https://www.cnblogs.com/68xi/p/13304310.html