服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服务器之家 - 编程语言 - PHP教程 - php获取bing每日壁纸示例分享

php获取bing每日壁纸示例分享

2020-06-12 16:46PHP教程网 PHP教程

这篇文章主要介绍了使用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');
 }
?>

 

延伸 · 阅读

精彩推荐