MENU

Catalog

博客必应每日壁纸

March 27, 2020 • 开发

该博客已经不再采用每日壁纸的方案,但是下文中的壁纸API依然能够使用

学了几天的工地PHP,捞出来康康,写bug半小时,修bug2小时

自己用PHP封装了一个Bing每日壁纸的API,供给博客首页的图片

首页查看效果

API

官方接口

http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1

Bing每日壁纸并不是每天换的

参数

  • format:api数据的输出格式,js为json,否则为XML
  • idx:指定日期,-1为明天,0为今天,1为昨天,以此类推,范围是[-1,15]
  • n :获取的图片数量,最大为8

JSON

{
    "images": [{
        "startdate": "20200326",
        "fullstartdate": "202003260700",
        "enddate": "20200327",
        "url": "/th?id=OHR.NoCaliCoast_EN-CN5564310554_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
        "urlbase": "/th?id=OHR.NoCaliCoast_EN-CN5564310554",
        "copyright": "Aerial view of the Big Sur coastline near Monterey, California (© Blue Planet Archive/Alamy)",
        "copyrightlink": "https://www.bing.com/search?q=Big+Sur&form=hpcapt&filters=HpDate%3a%2220200326_0700%22",
        "title": "Gray days ahead in Monterey",
        "quiz": "/search?q=Bing+homepage+quiz&filters=WQOskey:%22HPQuiz_20200326_NoCaliCoast%22&FORM=HPQUIZ",
        "wp": true,
        "hsh": "102246c41a049afc7128ad5cd3d2e71b",
        "drk": 1,
        "top": 1,
        "bot": 1,
        "hs": []
    }],
    "tooltips": {
        "loading": "Loading...",
        "previous": "Previous image",
        "next": "Next image",
        "walle": "This image is not available to download as wallpaper.",
        "walls": "Download this image. Use of this image is restricted to wallpaper only."
    }
}

可见$JSON->images[i]->url就是我们想要的,截下来在前面加上cn.bing.com就是图片地址了

可以通过修改URL中的1920x1080来达到修改分辨率的目的,支持1920x1080、1366x768、1024x768、480x800

部署

如果你想直接引用本站API,或者自己在服务器部署API

此处内容需要评论回复后方可阅读

Last Modified: February 17, 2022
Leave a Comment

4 Comments
  1. 你的机器还有流量限制?

    1. @灰常记忆白嫖的用完了就没了@(狂汗)

  2. 速度还挺快

    1. @林木木主题支持加速,用又拍云还能更棒.....可惜没备案@(委屈)