| 接口地址:http://apis.juhe.cn/fapig/nba/query |
|---|
| 返回格式:json |
| 请求方式:get/post |
| 请求示例:http://apis.juhe.cn/fapig/nba/query?key=freeapi |
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| key | string | 必填 | 聚合key 扫码关注公众号 |
| 名称 | 类型 | 说明 |
|---|---|---|
| reason | string | 返回说明 |
| result | obj | 返回结果集 |
| title | string | 联赛名称 |
| duration | string | 联赛赛季 |
| matchs | array | 赛事清单 |
| date | string | 比赛日期 |
| week | string | 星期 |
| list | array | 赛事场次 |
| time_start | string | 比赛开始时间 |
| status | string | 比赛状态,1未开赛 2进行中 3完赛 4延期 status_text |
| team1 | string | 队伍1 |
| team2 | string | 队伍2 |
| team1_score | string | 队伍1比分 |
| team2_score | string | 队伍2比分 |
{
"reason": "查询成功!",
"result": {
"title": "美国男子职业篮球联赛",
"duration": "2020-2021",
"matchs": [{
"date": "2021-05-13",
"week": "周四",
"list": [{
"time_start": "07:00",
"status": "3",
"status_text": "完赛",
"team1": "亚特兰大老鹰",
"team2": "华盛顿奇才",
"team1_score": "120",
"team2_score": "116"
},
{
"time_start": "08:00",
"status": "3",
"status_text": "完赛",
"team1": "布鲁克林篮网",
"team2": "圣安东尼奥马刺",
"team1_score": "128",
"team2_score": "116"
},
{
"time_start": "08:00",
"status": "3",
"status_text": "完赛",
"team1": "克里夫兰骑士",
"team2": "波士顿凯尔特人",
"team1_score": "102",
"team2_score": "94"
},
{
"time_start": "09:00",
"status": "3",
"status_text": "完赛",
"team1": "达拉斯独行侠",
"team2": "新奥尔良鹈鹕",
"team1_score": "125",
"team2_score": "107"
},
{
"time_start": "09:30",
"status": "3",
"status_text": "完赛",
"team1": "犹他爵士",
"team2": "波特兰开拓者",
"team1_score": "98",
"team2_score": "105"
}
]
}]
},
"error_code": 0
}| 错误码 | 说明 |
|---|---|
| 209201 | 球队名称不能为空 |
| 209202 | 查询不到NBA相关信息 |
| 209203 | 网络错误。请重试 |
| 209204 | 查询不到队伍赛程相关信息 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/01/03 19:08
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'http://apis.juhe.cn/fapig/nba/query?key=freeapi';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "http://apis.juhe.cn/fapig/nba/query?key=freeapi"
)
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))
}