Blame view

PolyvUtils.java 926 Bytes
涂亚平 committed
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
package com.subsidy.util;

import net.polyv.live.v1.util.LiveSignUtil;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

public class PolyvUtils {

    /**
     * 学生端--生成保利威视直播观看地址
     */
    public static String liveSign(String userId, String channelId){

        //根据实际情况设置userid
        String ts = String.valueOf(System.currentTimeMillis());
        String url = "https://live.polyv.cn/watch/"+channelId;
        String signText = "03sqxr97fo"+ userId +"03sqxr97fo"+ts;
        try {
            String sign = LiveSignUtil.md5Hex(signText);
            url += "?userid="+userId+"&ts="+ts+"&sign="+sign;
            return url;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

}