{ "code": 200, "msg": "success", "data": { "date": "20200308", "stories": [{ "image_hue": "0x83b37d", "title": "创伤后应激障碍(PTSD)与抑郁症状有何不同?", "url": "https://daily.zhihu.com/story/9721287", "hint": "Dr.M · 4 分钟阅读", "ga_prefix": "030820", "images": [ "https://pic1.zhimg.com/v2-9aaceb95917e280d789d092c15b54174.jpg" ], "type": 0, "id": 9721287 }, { "image_hue": "0x4f3e63", "title": "如果机器人可以做大部分工作,《资本论》还有效吗?", "url": "https://daily.zhihu.com/story/9721285", "hint": "Justin Lee · 4 分钟阅读", "ga_prefix": "030816", "images": [ "https://pic4.zhimg.com/v2-05eff424fb1d2ba8d6a9e2e75a514dc3.jpg" ], "type": 0, "id": 9721285 }, { "image_hue": "0xb3947d", "title": "如何看待网上五花八门的「寻人服务」?", "url": "https://daily.zhihu.com/story/9721278", "hint": "牛顿顿顿 · 10 分钟阅读", "ga_prefix": "030811", "images": [ "https://pic2.zhimg.com/v2-f5dcd108439e0c823510a416776b2665.jpg" ], "type": 0, "id": 9721278 }, { "image_hue": "0x6d4339", "title": "「买熊猫判十年,买妇女最重判三年」是真的吗?", "url": "https://daily.zhihu.com/story/9721271", "hint": "一丁 · 2 分钟阅读", "ga_prefix": "030809", "images": [ "https://pic4.zhimg.com/v2-d3394fb29a024638e78d66375142469b.jpg" ], "type": 0, "id": 9721271 }, { "image_hue": "0x3b4954", "title": "洗澡时,元素周期表里的元素挨个飞来会怎样?(二)", "url": "https://daily.zhihu.com/story/9721196", "hint": "老伏 · 8 分钟阅读", "ga_prefix": "030807", "images": [ "https://pic3.zhimg.com/v2-c649d98d3699c61a1f3df1ad52067c62.jpg" ], "type": 0, "id": 9721196 } ], "top_stories": [{ "image_hue": "0x3b4954", "hint": "作者 / 老伏", "url": "https://daily.zhihu.com/story/9721187", "image": "https://pic2.zhimg.com/v2-1bc6922cc3da00da1326fd15c7b9fc7d.jpg", "title": "假如你洗澡时,元素周期表里的元素挨个飞来会怎样?(一)", "ga_prefix": "030507", "type": 0, "id": 9721187 }, { "image_hue": "0x8f8864", "hint": "作者 / 一丁", "url": "https://daily.zhihu.com/story/9721127", "image": "https://pic4.zhimg.com/v2-b35cc03ed77a6f3bd4892722556b11e7.jpg", "title": "如何看待同人作品的法律风险?", "ga_prefix": "030409", "type": 0, "id": 9721127 }, { "image_hue": "0xb3947d", "hint": "作者 / 我是一只小萌刀", "url": "https://daily.zhihu.com/story/9720746", "image": "https://pic3.zhimg.com/v2-a2e68715865ee4717110c684ff34072e.jpg", "title": "历史上有哪些英雄人物在晚年对自己一生的评价?", "ga_prefix": "022411", "type": 0, "id": 9720746 }, { "image_hue": "0x051e27", "hint": "作者 / 羽则", "url": "https://daily.zhihu.com/story/9720668", "image": "https://pic2.zhimg.com/v2-162fbbfbf55aba80dc8a50c7f989d67d.jpg", "title": "你见过最野的黑客什么样?", "ga_prefix": "022209", "type": 0, "id": 9720668 }, { "image_hue": "0x736650", "hint": "作者 / Miss liz", "url": "https://daily.zhihu.com/story/9720198", "image": "https://pic1.zhimg.com/v2-f6a1c61c36fdf2968d3342b985bf1ac0.jpg", "title": "小事 · 串好的糖葫芦,堆在垃圾箱", "ga_prefix": "020922", "type": 0, "id": 9720198 } ] }, "Author": { "name": "Alone88", "desc": "由Alone88提供的免费API 服务,官方文档:www.alapi.cn" } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/02/01 00:16 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://v1.alapi.cn/api/tophub/get'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "https://v1.alapi.cn/api/tophub/get" ) func main() { queryUrl := fmt.Sprintf("%s",APIURL) resp, err := http.Get(queryUrl) if err != nil { log.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }