{ "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 }] }, "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/zhihu/latest'; } /** * 获取结果 * @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/zhihu/latest" ) 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)) }