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

 更新时间:2014年02月25日 09:59:52   作者:  
这篇文章主要介绍了使用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');
 }
?>

相关文章

最新评论