高稳定性、海量、迅速的免费一言API服务
API地址(来自极客guochengjie)
http(s)://api.guoch.xyz 托管于景安,由PHP7.1驱动,腾讯云提供国内CDN加速,由TrustAisa提供TLS/SSL证书。无SLA保证但理论可用率达99%。
调用方式
JS方式
GET请求 https://api.guoch.xyz/?code=js
实例:curl https://api.guoch.xyz/?code=js
输出效果:function saying(){document.write("如果一次也不回头,我能走到哪里呢?");}
网页引用
将下面这段代码放入页面内需要 展示一句话 的位置即可
<script type="text/javascript" src="https://api.guoch.xyz/?code=js&charset=utf-8"></script>
<div id="saying"><script>saying()</script></div>
这样输出的样式可能会比较丑,如果你懂 CSS 的话可以自己再美化一下。也可以先试下我这边写好的 css 代码(可以加到自己的 style.css里面):
#saying{
border-left: 5px solid #2f889a;
border-right: 5px solid #2f889a;
background-color: #ebebeb;
padding: 10px;text-align: center;
color: #095AD4;
margin: 5px 0 5px 0;
}
这是一个最简单的调用实例,这也许并不是最好的方式;使用 Ajax 技术异步请求 JsonP 或 Json 接口会是更好的选择,但这类代码需要根据站点实际情况来编写。
iframe 方式
<hr />
<iframe align="center" width="100%" height="20" src="https://api.guoch.xyz" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
TXT/XML格式
直接GET请求https://api.guoch.xyz
实例:curl https://api.guoch.xyz
输出效果:光芒是不可能照遍所有的地方的,有光的地方就一定有影子。
json格式
GET请求 https://api.guoch.xyz/?code=json
实例: curl https://api.guoch.xyz/?code=json
返回效果:
{"code":200,"msg":"\u4e0d\u662f\u5f3a\u8005\u5fc5\u80dc\uff0c\u800c\u662f\u80dc\u8005\u5fc5\u5f3a\uff0c\u4ed6\u4eec\u6bd4\u6211\u4eec\u5f3a\uff0c\u4ec5\u6b64\u800c\u5df2\u3002"}
ARRAY格式
GET https://api.guoch.xyz/?code=array
或者 https://api.guoch.xyz/?code=arr
输出效果:array(2) { ["code"]=> int(200) ["msg"]=> string(54) "也许我们都没有长大,只是世界变小了。" }
前人栽树、后人乘凉,Sanci在此感谢 原作者、次作者、贡献者 等等。。。
放狗一搜,网上关于一言的版本有很多,此文API源自:https://api.guoch.xyz/