当前位置:首页 > PHP教程 > 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');
 }
?>



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!