日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php篮球比赛,篮球数据API接口 - 【篮球比赛动画直播变化数据】API调用示例代码...

發布時間:2024/10/8 php 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php篮球比赛,篮球数据API接口 - 【篮球比赛动画直播变化数据】API调用示例代码... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

籃球比賽動畫直播變化數據API調用示例,詳細請查看在線文檔,需注冊下

package com.huaying.demo.basketball;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.Unmarshaller;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlRootElement;

import java.io.ByteArrayInputStream;

import java.nio.charset.StandardCharsets;

import java.nio.file.Files;

import java.nio.file.Paths;

import java.util.List;

import java.util.stream.Collectors;

/**

* 22.籃球比賽動畫直播變化數據

*

* @Website: https://www.feijing88.com

*/

public class BasketballAnimationLiveChange {

public static void main(String[] args) {

try {

String content = getContent();

JAXBContext jaxbContext = JAXBContext.newInstance(ResultList.class);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

ResultList list = (ResultList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes()));

list.getResultList().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/BasketballAnimationLive.xml"), StandardCharsets.UTF_8);

lines.forEach(line -> builder.append(line));

return builder.toString();

} catch (Throwable t) {

t.printStackTrace();

return "";

}

}

@XmlRootElement(name = "c")

public static class ResultList {

@XmlElement(name = "match")

private List itemList;

public List getResultList() {

return itemList.stream()

.map(AnimationLive::parse)

.collect(Collectors.toList());

}

}

private static class AnimationLive {

@XmlElement(name = "f")

private String data;

private String matchInfo;

private String animationLive;

public AnimationLive parse() {

String[] values = data.split("!");

matchInfo = getData(values, 0);

animationLive = getData(values, 1);

return this;

}

private String getData(String[] values, int index) {

if (index >= 0 && index < values.length) {

return values[index];

} else {

return null;

}

}

@Override

public String toString() {

return "AnimationLive{" +

"matchInfo='" + matchInfo + '\'' +

", animationLive='" + animationLive + '\'' +

'}';

}

}

}

API 返回數據如下(部分):

AnimationLive{matchInfo='365898^1679^84^/files/team/20190124183405.jpg^/files/team/20190124185630.jpg^4', animationLive='3430861,0,12,-1,,0'}

AnimationLive{matchInfo='365903^1576^1577^/files/team/20190124182112.jpg^/files/team/20190124181344.jpg^4', animationLive='3430982,0,12,-1,,0'}

AnimationLive{matchInfo='365921^83^723^/files/team/20190124175730.jpg^/files/team/20190124184900.jpg^-1', animationLive='3430956,0,12,-1,,0'}

AnimationLive{matchInfo='365902^732^2079^/files/team/20190124182503.jpg^/files/team/20190124184216.jpg^-1', animationLive='3431088,0,12,-1,,0'}

AnimationLive{matchInfo='353406^73^76^/files/team/73.gif^/files/team/20180508172444.png^-1', animationLive='3433286,0,12,-1,,0'}

AnimationLive{matchInfo='353407^69^707^/files/team/20181110020130.jpg^/files/team/707.jpg^4', animationLive='3433268,0,12,-1,,0'}

AnimationLive{matchInfo='353408^66^75^/files/team/20160426141738.jpg^/files/team/75.gif^4', animationLive='3433215,0,12,-1,,0'}

AnimationLive{matchInfo='353409^67^65^/files/team/67.gif^/files/team/20181110022755.jpg^4', animationLive='3433214,0,12,-1,,0'}

AnimationLive{matchInfo='353410^2013^68^/files/team/2013.gif^/files/team/68.gif^4', animationLive='3433091,0,12,-1,,0'}

AnimationLive{matchInfo='353411^71^72^/files/team/71.gif^/files/team/20181110022628.jpg^-1', animationLive='3433226,0,12,-1,,0'}

AnimationLive{matchInfo='365916^2434^85^/files/team/20190124190057.jpg^/files/team/20190124183337.jpg^0', animationLive='null'}

總結

以上是生活随笔為你收集整理的php篮球比赛,篮球数据API接口 - 【篮球比赛动画直播变化数据】API调用示例代码...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。