最近发现了一个比较不错的应用——ONE(一个),每天只为你准备一张图片、一篇文字和一个问答,打开之后就立马喜欢上了
复杂世界里, 一个就够了. One is all.
这两句品牌标语我也非常喜欢。
想着把这个每日一语添加到博客上,这里直接写了一个API接口
食用方法
$.ajax({
type: "POST",
url: 'https://api.hibai.cn/api/index/index',
dataType: 'json',
data: {"TransCode":"030111","OpenId":"123456789","Body":""},
success: function(result){
$(".description").text(result.Body.word+' ———— 「ONE · 一个」');
return false;
}
});
获取到json信息
{
"ResultCode": 1,
"ErrCode": "OK",
"Body": {
"vol": "VOL.1961",
"img_url": "http://image.wufazhuce.com/FnLVOKa7hPmA4wd1rSIDgEFgFwFS",//图片URL
"img_author": "罗昊",//图片作者
"img_kind": "摄影",//图片类型
"date": "2018-02-18 06:00:00",//时间
"url": "http://m.wufazhuce.com/one/1991",
"word": "时间其实是很公平的,经过时间,你所爱的人,所恨的人,都会变成鬼影子,在记忆中毫无理由地走来走去。",//文字
"word_from": "《少年巴比伦》",//文字来源
"id": "1991"
}
}
此处的$(".description").text(result.Body.word+' ———— 「ONE · 一个」');
是设置标签的class属性为description的div上显示一篇文字,根据你需要进行不同的设置
更改请求码TransCode的值为030112即可
获取到json信息
{
"ResultCode": 1,
"ErrCode": "OK",
"Body": [
{
"vol": "VOL.1961",
"img_url": "http://image.wufazhuce.com/FnLVOKa7hPmA4wd1rSIDgEFgFwFS",
"img_author": "罗昊",
"img_kind": "摄影",
"date": "2018-02-18 06:00:00",
"url": "http://m.wufazhuce.com/one/1991",
"word": "时间其实是很公平的,经过时间,你所爱的人,所恨的人,都会变成鬼影子,在记忆中毫无理由地走来走去。",
"word_from": "《少年巴比伦》",
"id": "1991"
},
{
"vol": "VOL.1960",
"img_url": "http://image.wufazhuce.com/Fjp6hwvSOZbIjVrXw0SsSV1LN-rJ",
"img_author": "狐狸狐狸鱼",
"img_kind": "插画",
"date": "2018-02-17 06:00:00",
"url": "http://m.wufazhuce.com/one/1990",
"word": "人生的转折点并非出现在急转直下的时刻,而是隐藏在之前。就像小说的结局并不出现在最后一章,而是当主角错过最后一个补救的机会,更好的选择悄然消失的时候,故事的结局就已经开始了。人生也一样,在真正的衰败到来之前,一个隐微的起点,一个看似容易抹过去的裂缝,甚至是一个聚光灯下的高光时刻,然后就开始走向失败。",
"word_from": "蒋方舟",
"id": "1990"
},
{
"vol": "VOL.1959",
"img_url": "http://image.wufazhuce.com/FoCDKbpGIOedXx26owKQzHlMyO5y",
"img_author": "黄雷蕾Linali",
"img_kind": "插画",
"date": "2018-02-16 06:00:00",
"url": "http://m.wufazhuce.com/one/1989",
"word": "Every dog has its day.\r\n狗富贵,勿相忘。",
"word_from": "一个App工作室",
"id": "1989"
},
{
"vol": "VOL.1958",
"img_url": "http://image.wufazhuce.com/FlAg5B17YIhVv8hUX8b6CwJkl4O6",
"img_author": "Drew Farwell",
"img_kind": "摄影",
"date": "2018-02-15 06:00:00",
"url": "http://m.wufazhuce.com/one/1988",
"word": "过年对我的好处是,我总算有一个理由告诉自己,今天不要沮丧。收拾一下自己,穿上新买的外套去外面看看,游荡时看到的每一件事都愿意分享,原来世界已大不一样。 ",
"word_from": "姬霄",
"id": "1988"
},
{
"vol": "VOL.1957",
"img_url": "http://image.wufazhuce.com/FtcXHjeXKrShdeFa9zGb9TDqEsef",
"img_author": "Shifaaz Shamoon",
"img_kind": "摄影",
"date": "2018-02-14 06:00:00",
"url": "http://m.wufazhuce.com/one/1987",
"word": "你是你自己,一生的情人。",
"word_from": " 张晓晗",
"id": "1987"
},
{
"vol": "VOL.1956",
"img_url": "http://image.wufazhuce.com/FsxKp6ob3iKt6dzh5bHtc0FhN51v",
"img_author": "朱宝元",
"img_kind": "插画",
"date": "2018-02-13 06:00:00",
"url": "http://m.wufazhuce.com/one/1986",
"word": "这世上有一半的人永远也不知道另一半人是如何生活的。真理都在千百年前被说尽了,而试图打破次元壁,试图充当桥梁的人,却会被嘲笑。就像爬出洞穴的那个人,说破嘴也无法让洞穴里的人相信真实世界的存在。",
"word_from": "姚瑶",
"id": "1986"
},
{
"vol": "VOL.1955",
"img_url": "http://image.wufazhuce.com/FmTR3gmE5YJ4L3ub-EFyMVY3YX-F",
"img_author": "曹迪",
"img_kind": "摄影",
"date": "2018-02-12 06:00:00",
"url": "http://m.wufazhuce.com/one/1985",
"word": "在两个人的感情世界中,一锤定音的,不是心有灵犀的睿智,不是旗鼓相当的欣赏,更不是死心塌地的仰望。是心疼,是怜惜。是两难境地里,那一点点无可奈何的舍不得。",
"word_from": "八月长安",
"id": "1985"
},
{
"vol": "VOL.1954",
"img_url": "http://image.wufazhuce.com/FhdhANkTyRuzgX3edvvrUz22hFBQ",
"img_author": "Robin 彬仔",
"img_kind": "插画",
"date": "2018-02-11 06:00:00",
"url": "http://m.wufazhuce.com/one/1984",
"word": "为了使灵魂宁静,一个人每天要做两件他不喜欢的事。",
"word_from": "毛姆",
"id": "1984"
},
{
"vol": "VOL.1953",
"img_url": "http://image.wufazhuce.com/Fk98vnLABFxpednHCCtKODndVvh6",
"img_author": "黄雷蕾Linali",
"img_kind": "插画",
"date": "2018-02-10 06:00:00",
"url": "http://m.wufazhuce.com/one/1983",
"word": "所有感情都没有过分夸大的必要,因为没有什么只开始不结束。小时候觉得一辈子都不会弄丢的东西,最后也毫不心疼地丢弃了。亲情,爱情,友情,都会慢慢失去,有的自然而然,有的姿势难看。但感情的事,不就是这个样子吗。",
"word_from": "《生活上瘾指南》",
"id": "1983"
},
{
"vol": "VOL.1952",
"img_url": "http://image.wufazhuce.com/FnaFxPLiwQrl3WYqfeQVbMSZyGmA",
"img_author": "Jordan Whitt",
"img_kind": "摄影",
"date": "2018-02-09 06:00:00",
"url": "http://m.wufazhuce.com/one/1982",
"word": "运用一个你其实并不懂的词,这根本是犯罪,就像一个人心中没有爱却说我爱你一样。",
"word_from": "《房思琪的初恋乐园》",
"id": "1982"
}
]
}
根据你的需要对返回的数据进行处理即可
更多API的使用方法请前往原文查看