您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> php编程 >> 正文

php获取bing每日壁纸的示例

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 这篇文章主要介绍了使用php获取bing每日壁纸的示例,需要的朋友可以参考下

  代码如下: <?php  $str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&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');  } ?>