mirror of
https://github.com/zhxycn/BingWallpaperAPI.git
synced 2024-11-29 13:50:35 +00:00
Update index.php
This commit is contained in:
parent
76124fad39
commit
c09c092dc3
31
index.php
31
index.php
@ -1,16 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
function a() {
|
$ago = '0'; // 时间 (几天前。0为今天,1为昨天,2为前天,以此类推。)
|
||||||
$ago = '0'; // 设定图片的时间(几天前。0为今天,1为昨天,2为前天,-1为明天,以此类推,由于调用的是必应国内版,当日16至次日16时为一张壁纸。)
|
$region = '1'; // 位置(必应国际版填0,国内版填1。)
|
||||||
$data = json_decode(file_get_contents('https://cn.bing.com/HPImageArchive.aspx?format=js&idx='.$ago.'&n=1&mkt=zh-CN'), true);
|
// 必应国内版当日16至次日16时为一张壁纸。
|
||||||
return "https://cn.bing.com".$data['images'][0]['url'];
|
|
||||||
};
|
if ($_GET['region'] == 'global') {
|
||||||
$url = a();
|
$region = '0';
|
||||||
|
} elseif ($_GET['region'] == 'cn') {
|
||||||
|
$region = '1';
|
||||||
|
} else {
|
||||||
|
$region = $region;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($region == '0') {
|
||||||
|
$data = json_decode(file_get_contents('https://bing.com/HPImageArchive.aspx?format=js&idx='.$ago.'&n=1'), true);
|
||||||
|
$url = "https://bing.com".$data['images'][0]['url'];
|
||||||
|
} elseif ($region == '1') {
|
||||||
|
$data = json_decode(file_get_contents('https://cn.bing.com/HPImageArchive.aspx?format=js&idx='.$ago.'&n=1&mkt=zh-CN'), true);
|
||||||
|
$url = "https://cn.bing.com".$data['images'][0]['url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$date = $data['images'][0]['startdate'];
|
||||||
|
$copyright = $data['images'][0]['copyright'];
|
||||||
|
|
||||||
if ($_GET['encode'] == 'json') {
|
if ($_GET['encode'] == 'json') {
|
||||||
$echo = array('url' => $url);
|
$echo = array('date' => $date, 'url' => $url, 'copyright' => $copyright);
|
||||||
echo json_encode($echo);
|
echo json_encode($echo);
|
||||||
} else {
|
} else {
|
||||||
header("Location:$url");
|
header("Location:$url");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user