CS:GO API电竞数据接口【战队列表】数据库调用示例代码
CS:GO电竞API专用数据接口 分享使用代码
分享使用 野子数据 http://www.yezishuju.com/ 电竞API数据接口调用的示例代码
接口分为:
CS:GO【战队列表】
CS:GO【选手信息】
CS:GO【历史对战】
CS:GO【赛事数据】
CS:GO【赛事列表】
示例演示:CSGO的【战队列表】接口
具体如下:
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
@API: 战队列表
@Website: http://www.yezishuju.com/
*/
public class CsgoLeague {
public static void main(String[] args) {
try {
String content = getContent();
Respond rsp = JSON.parseObject(content, Respond.class);
System.out.println(rsp.code);
System.out.println(rsp.message);
rsp.getLeagueList().forEach(System.out::println);
} catch (Throwable t) {
t.printStackTrace();
}
}
/**
获取API返回内容
Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
*/
private static String getContent() {
try {
StringBuilder builder = new StringBuilder();
List lines = Files.readAllLines(Paths.get("./src/main/resources/CsgoLeague.json"), StandardCharsets.UTF_8);
lines.forEach(builder::append);
return builder.toString();
} catch (Throwable t) {
t.printStackTrace();
return “”;
}
}
public static class Respond {
@JSONField(name = “code”)
private int code;
@JSONField(name = “message”)
private String message;
@JSONField(name = “data”)
private List leagueList;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<League> getLeagueList() {
return leagueList;
}
public void setLeagueList(List<League> leagueList) {
this.leagueList = leagueList;
}
}
public static class League {
@JSONField(name = “league_id”)
private int leagueId;
@JSONField(name = “logo”)
private String logo;
@JSONField(name = “name”)
private String name;
@JSONField(name = “country”)
private String country;
@JSONField(name = “location”)
private String location;
@JSONField(name = “start_time”)
private long startTime;
@JSONField(name = “end_time”)
private long endTime;
@JSONField(name = “team_ids”)
private List teamIds;
@JSONField(name = “status”)
private int status;
@Override
public String toString() {
return "League{" +
"leagueId=" + leagueId +
", logo='" + logo + '\'' +
", name='" + name + '\'' +
", country='" + country + '\'' +
", location='" + location + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", teamIds=" + teamIds +
", status=" + status +
'}';
}
public int getLeagueId() {
return leagueId;
}
public void setLeagueId(int leagueId) {
this.leagueId = leagueId;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public List<Integer> getTeamIds() {
return teamIds;
}
public void setTeamIds(List<Integer> teamIds) {
this.teamIds = teamIds;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
上一篇: 电竞CSGO数据API接口 - 【近期赛事列表】API调用示例代码
下一篇: 男人们必知的人生定律
推荐阅读
-
CSGO电竞API数据接口 - 【选手信息】API调用示例代码
-
电竞CSGO数据API接口 - 【战队列表】API调用示例代码
-
电竞CSGO数据API接口 - 【战队数据列表】API调用示例代码
-
Dota2电竞API数据接口 - 【战队列表】API调用示例代码
-
CSGO电竞API数据接口 - 【战队列表】API调用示例代码
-
电竞Dota2数据API接口 - 【战队列表】API调用示例代码
-
电竞CSGO数据API接口 - 【近期赛事列表】API调用示例代码
-
CS:GO API电竞数据接口【战队列表】数据库调用示例代码
-
电竞CSGO数据API接口 - 【最近赛事列表】API调用示例代码
-
电竞CSGO数据API接口 - 【联赛列表】API调用示例代码