CSGO电竞API数据接口【West S2战队数据】分享使用演示

码农天地 -
CSGO电竞API数据接口【West S2战队数据】分享使用演示

West S2战队数据 电竞API专用电竞数据接口 分享使用代码

示例演示:【West S2战队数据】
分享使用 野子数据 http://yes-esports.com/ 电竞API数据接口调用的示例代码

具体如下:
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: https://www.xxe.io/
@Website: http://www.yesesport.com/
@Website: http://www.yezidianjing.com/
*/
public class CsgoMatch {

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.getMatchList().forEach(System.out::println);

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/yxlm/
 */
public class LolPlayer {
 
    public static void main(String[] args) {
        try {
            String content = getContent();
            Respond rsp = JSON.parseObject(content, Respond.class);
            System.out.println(rsp);
 
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
 
    /**
     * 获取API返回内容
     * <p>
     * Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
     */
    private static String getContent() {
        try {
            StringBuilder builder = new StringBuilder();
            List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/LolPlayer.json"), StandardCharsets.UTF_8);
            lines.forEach(builder::append);
            return builder.toString();
        } catch (Throwable t) {
            t.printStackTrace();
            return "";
        }
    }
 
    public static class Respond {
        @JSONField
        private int code;
        @JSONField
        private String message;
        @JSONField
        private Player data;
 
        @Override
        public String toString() {
            return "Respond{" +
                    "code=" + code +
                    ", message='" + message + '\'' +
                    ", data=" + data +
                    '}';
        }
 
        public void setCode(int code) {
            this.code = code;
        }
 
        public void setMessage(String message) {
            this.message = message;
        }
 
        public void setData(Player data) {
            this.data = data;
        }
    }
 
    public static class Player {
 
        @JSONField
        private int playerId;
        @JSONField
        private int teamId;
        @JSONField
        private String avatar;
        @JSONField
        private String nickName;
        @JSONField
        private String realName;
        @JSONField
        private String position;
        @JSONField
        private String country;
        @JSONField
        private String introduction;
 
        @Override
        public String toString() {
            return "Player{" +
                    "playerId=" + playerId +
                    ", teamId=" + teamId +
                    ", avatar='" + avatar + '\'' +
                    ", nickName='" + nickName + '\'' +
                    ", realName='" + realName + '\'' +
                    ", position='" + position + '\'' +
                    ", country='" + country + '\'' +
//                    ", introduction='" + introduction + '\'' +
                    '}';
        }
 
        public void setPlayerId(int playerId) {
            this.playerId = playerId;
        }
 
        public void setTeamId(int teamId) {
            this.teamId = teamId;
        }
 
        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }
 
        public void setNickName(String nickName) {
            this.nickName = nickName;
        }
 
        public void setRealName(String realName) {
            this.realName = realName;
        }
 
        public void setPosition(String position) {
            this.position = position;
        }
 
        public void setCountry(String country) {
            this.country = country;
        }
 
        public void setIntroduction(String introduction) {
            this.introduction = introduction;
        }
    }
 
}

API 返回数据如下(部分):

Respond{code=200, message='成功', data=Player{playerId=1, teamId=6, avatar='http://www.yezishuju.com/templets/V3/list/Picture/2.png', nickName='clearlove', realName='明凯', position='打野', country='中国'}}
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

php介绍

PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。PHP独特的语法混合了C、Java、Perl以及 PHP 自创的语法。利于学习,使用广泛,主要适用于Web开发领域。

Tags 标签

javascriptphp

扩展阅读

加个好友,技术交流

1628738909466805.jpg