Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
新增测试版
Browse files Browse the repository at this point in the history
  • Loading branch information
tnqzh123 committed Jun 10, 2017
1 parent 1009aea commit faa5da3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
48 changes: 48 additions & 0 deletions bingpic-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
辣鸡 Bing 今日美图 API 测试版 By Little_Qiu
Version: 1.2-test
感谢 @GPlane
这是辣鸡 Bing 今日美图 API 的测试版。
该版本可能未开发完全的或含有不稳定因素,请谨慎用于生产环境!
*/

// 检查 PHP 版本(然而并没有什么卵用)
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
exit('错误:辣鸡 Bing 今日美图 API 要求 PHP 版本不低于 5.2.0,你正在使用的是 '.PHP_VERSION);
}

// 获取 Bing 今日美图的图片地址
function bg() {

// 导入设置
include 'settings.php';

// 检查是否使用固定时间
if (useurl) {

// 获取参数
$daysagoquery = "$_GET[daysago]";

// 获取 JSON
$data = json_decode(file_get_contents("http://cn.bing.com/HPImageArchive.aspx?format=js&idx=$daysagoquery&n=1"), true);

} else {

// 获取 JSON
$data = json_decode(file_get_contents("http://cn.bing.com/HPImageArchive.aspx?format=js&idx=$daysago&n=1"), true);

};

// 返回 URL
return "https://cn.bing.com".$data['images'][0]['url'];

};

// 302 跳转
$url = bg();
header("Location: $url");
exit;

?>
3 changes: 3 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

// 是否使用固定的时间
$useurl = false;

// 设置时间(几天前),将 0 修改为你需要的时间
$daysago = '0';

Expand Down

0 comments on commit faa5da3

Please sign in to comment.