{ "code": 200, "msg": "success", "data": { "current_page": 1, "data": [{ "title": "【笑话】上次晚上开车遇到对面大货车灯光太刺眼了", "content": "<p>#笑话# 上次晚上开车遇到对面大货车灯光太刺眼了,我提示了几次,还不见他切换,妈的我这暴脾气起来了,开着远光灯对射谁怕谁!哪知道对面大货车把灯光一调,我感觉我看到了太阳。</p>", "unixtime": "1583383675", "date": "2020-03-05 12:47:55" }], "first_page_url": "http://v1.alapi.cn/api/joke?page=1", "from": 1, "last_page": 341, "last_page_url": "http://v1.alapi.cn/api/joke?page=341", "next_page_url": "http://v1.alapi.cn/api/joke?page=2", "path": "http://v1.alapi.cn/api/joke", "per_page": 10, "prev_page_url": null, "to": 10, "total": 3408 }, "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/joke'; } /** * 获取结果 * @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/joke" ) 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)) }