admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.newvideo.zhibo.ljf;
 
import java.util.ArrayList;
import java.util.List;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.newvideo.util.HttpUtil;
import com.newvideo.util.StringUtil;
import com.newvideo.zhibo.ljf.entity.LJFLiveData;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
public class LiuJianFangApi {
    public final static String TYPE_ALL = "";
    public final static String TYPE_HAOSHENGYING = "u0";
    public final static String TYPE_JINGBAO = "u1";
    public final static String TYPE_GAOXIAO = "u2";
    public final static String TYPE_LAOKE = "u3";
 
    public static List<LJFLiveData> liveList(String type, int page) {
        long time = System.currentTimeMillis() / 1000;
        String loginKey = "jaAFDFGHT#[js10000]_GU";
        String sign = StringUtil.Md5("buwan" + time + loginKey);
        String url = String.format(
                "http://v.6.cn/coop/pub/getLiveList.php?act=livelist&coopsrc=buwan&type=%s&tm=%s&flag=%s&limit=30&page=%s",
                type, time + "", sign, page + "");
        String result = HttpUtil.get(url);
        List<LJFLiveData> list = new ArrayList<LJFLiveData>();
        if("get data empty".equals(result)){
            return list;
        }
        JSONObject data = JSONObject.fromObject(result);
        // int roomTotal = data.optInt("roomTotal");
        JSONArray array = data.optJSONArray("roomList");
        Gson gson = new GsonBuilder().create();
        if (array != null)
            for (int i = 0; i < array.size(); i++) {
                LJFLiveData liveData = gson.fromJson(array.optJSONObject(i).toString(), LJFLiveData.class);
                list.add(liveData);
            }
        return list;
    }
    
    public static List<LJFLiveData> liveList(String type, int page,int pageSize) {
        long time = System.currentTimeMillis() / 1000;
        String loginKey = "jaAFDFGHT#[js10000]_GU";
        String sign = StringUtil.Md5("buwan" + time + loginKey);
        String url = String.format(
                "http://v.6.cn/coop/pub/getLiveList.php?act=livelist&coopsrc=buwan&type=%s&tm=%s&flag=%s&limit="+pageSize+"&page=%s",
                type, time + "", sign, page + "");
        String result = HttpUtil.get(url);
        JSONObject data = JSONObject.fromObject(result);
        // int roomTotal = data.optInt("roomTotal");
        JSONArray array = data.optJSONArray("roomList");
        Gson gson = new GsonBuilder().create();
        List<LJFLiveData> list = new ArrayList<LJFLiveData>();
        if (array != null)
            for (int i = 0; i < array.size(); i++) {
                LJFLiveData liveData = gson.fromJson(array.optJSONObject(i).toString(), LJFLiveData.class);
                list.add(liveData);
            }
        return list;
    }
 
}