1.1 获取直播活动信息接口.md
4.1 KB
/* Title: 1.1 获取某直播活动信息接口 */
接口描述
接口地址
http://api.cnlive.com/open/api2/zbsc/getLiveActivityPlayInfo
接口协议
HTTP GET
接口请求参数
| 参数名 | 参数类型 | 必选 | 参数说明 |
|---|---|---|---|
| sp_id | string | true | 应用ID |
| activityid | string | true | 由开发者通过API创建接口或者在直播云管理端创建,保证唯一性 |
| timestamp | int | true | 精确到秒,当前Unix时间戳,请保证请求服务器时间正确 |
| sign | String | true | 签名规则见签名详情 |
返回值
返回JSON格式的节目元数据信息,json示例如下:
{
"errorCode":"0",
"messagae":"请求成功",
"data"{
"activitystatus":"1",
"activityname":"测试活动",
"coverImgUrl":"小图图片URL",
"smallImg":"小图图片URL",
"bigImg":"大图图片URL",
“isHorizontalScreen”:“1”,
“channelID”:“xinyingshi”,
“startTime”:“”,
“EndTime”:“”,
“CreateTime”:“”,
“extensions”:“”,
“activityCategory”:“”,
"mp4_url_rate1":"",
"mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi&rate=2&sp_id=iqhpk8pl19",
"mp4_url_rate3":"",
"mp4_url_rate4":"",
"hls_url_rate1":"",
"hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi&rate=2&sp_id=iqhpk8pl19",
"hls_url_rate3":""
"hls_url_rate4":""
extViews[
{
"mp4_url_rate1":"",
"mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi_m1&rate=2&sp_id=iqhpk8pl19",
"mp4_url_rate3":"",
"mp4_url_rate4":"",
"hls_url_rate1":"",
"hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi_m1&rate=2&sp_id=iqhpk8pl19",
"hls_url_rate3":""
"hls_url_rate4":""
}
{
"mp4_url_rate1":"",
"mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi_m2&rate=2&sp_id=iqhpk8pl19",
"mp4_url_rate3":"",
"mp4_url_rate4":"",
"hls_url_rate1":"",
"hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi_m2&rate=2&sp_id=iqhpk8pl19",
"hls_url_rate3":""
"hls_url_rate4":""
}
}
}
}
public String getPlayVideo(ModelMap model,HttpServletRequest request) {
String result = "";
Map params = new HashMap<>();
params.put("sp_id", "iqhpk8pl19");
params.put("customID", "d849bb4277be42799df3ffc21654d949");
params.put("timestamp", System.currentTimeMillis()/1000+"");
String url = OpenUtil.buildURL("http://api.cnlive.com/open/api2/zbsc/getLiveActivityPlayInfo", params, "672db30805f848f59ec3728f8347a4a0");
HttpURLConnection connection;
try {
URL requestUrl = new URL(url);
connection = (HttpURLConnection)requestUrl.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();//连接
//获得返回值
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStream in = connection.getInputStream();
String currentLine = "";
if(in != null){
BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8"));
while((currentLine = br.readLine()) != null){
result += currentLine;
}
br.close();
}
}
}catch (Exception e) {
e.printStackTrace();
}
if(BaseUtil.notBlank(result)) {
JSONObject resultJson = JSONObject.parseObject(result);
model.put("videoInfo", resultJson);
}
return "play_demo";
}