当前位置:网站首页 / 建站 / 正文

php获取bing每日图片代码

时间:2018年08月18日 | 作者 : liuhui | 分类 : 建站 | 浏览: 5725次 | 评论 0

阿里云限量代金券 | 此广告位出租25元/月

将下面代码保存为bing.php,使用方法为:

<?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');
}
?>

html调用代码

<img src="bing.php" alt="tu" />

今日图片

tu

推荐您阅读更多有关于“”的文章

猜你喜欢

网站分类
关注电脑博士
友情链接

分享:

支付宝

微信