mirror of
https://github.com/zhxycn/BingWallpaperAPI.git
synced 2024-11-25 03:09:40 +00:00
Update index.php
This commit is contained in:
parent
3c4a006269
commit
afb5b6346a
54
index.php
54
index.php
@ -1,31 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
$ago = '0'; // 时间 (几天前。0为今天,1为昨天,2为前天,以此类推。)
|
// GitHub: https://github.com/zhxycn/BingWallpaperAPI
|
||||||
$region = '1'; // 位置(必应国际版填0,国内版填1。)
|
$ago = '0'; //How many days ago
|
||||||
// 必应国内版当日16至次日16时为一张壁纸。
|
$region = '0'; //Bing region
|
||||||
|
|
||||||
if ($_GET['region'] == 'global') {
|
$ago = $_REQUEST['ago'];
|
||||||
$region = '0';
|
if ($_REQUEST['region'] == 'global') {
|
||||||
} elseif ($_GET['region'] == 'cn') {
|
$region = '0';
|
||||||
$region = '1';
|
} elseif ($_REQUEST['region'] == 'cn') {
|
||||||
} else {
|
$region = '1';
|
||||||
$region = $region;
|
} else {
|
||||||
}
|
$region = $region;
|
||||||
|
}
|
||||||
if ($region == '0') {
|
if ($region == '0') {
|
||||||
$data = json_decode(file_get_contents('https://bing.com/HPImageArchive.aspx?format=js&idx='.$ago.'&n=1'), true);
|
$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'];
|
$url = "https://bing.com" . $data['images'][0]['url'];
|
||||||
} elseif ($region == '1') {
|
} 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);
|
$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'];
|
$url = "https://cn.bing.com" . $data['images'][0]['url'];
|
||||||
}
|
}
|
||||||
|
$date = $data['images'][0]['startdate'];
|
||||||
$date = $data['images'][0]['startdate'];
|
$copyright = $data['images'][0]['copyright'];
|
||||||
$copyright = $data['images'][0]['copyright'];
|
if ($_REQUEST['encode'] == 'json') {
|
||||||
|
$echo = array('date' => $date, 'url' => $url, 'copyright' => $copyright);
|
||||||
if ($_GET['encode'] == 'json') {
|
echo json_encode($echo);
|
||||||
$echo = array('date' => $date, 'url' => $url, 'copyright' => $copyright);
|
} else {
|
||||||
echo json_encode($echo);
|
header("Location:$url");
|
||||||
} else {
|
}
|
||||||
header("Location:$url");
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user