using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json; namespace Common { /// /// 与第三方TV云端对接:将语音文字上报 /// public static class TVOperation { private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(TVOperation)); //private static readonly string _iptvURL = "http://iot.gooorun.com:8282/uis/smartVoiceSkill/commonSmartPreInterceptor"; //http://192.168.1.210:8888/epg/api/audioControl/control //private static readonly string _tclURL = ""; //private static readonly string _tclAppKey = "4a4b4c125608"; //private static readonly string _tclAppSecret = "4a4b4c125608"; /// /// 远程控制IPTV /// /// /// 控制地址 /// /// /// public static bool ReportIPTV(string tvControlToken, string tvControlUrl, string hotelCode, string roomNumber, string value) { if (!string.IsNullOrEmpty(tvControlUrl)) { try { if (string.IsNullOrEmpty(tvControlToken)) { tvControlToken = "DEFAULT_TOKEN"; } IPTVPostData postData = new IPTVPostData() { token = tvControlToken, hotelId = "",//hotelCode roomId = roomNumber, value = value }; string param = Newtonsoft.Json.JsonConvert.SerializeObject(postData); string result = HttpWebRequestHelper.PostWebRequest(tvControlUrl, param); IPTVPostDataResult returnResult = JsonConvert.DeserializeObject(result); if (returnResult.retCode == "1") { return true; } logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败:{3}", hotelCode, roomNumber, tvControlUrl, returnResult.retMsg)); return false; } catch (Exception ex) { logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败:{3}", hotelCode, roomNumber, tvControlUrl, ex)); return false; } } logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败", hotelCode, roomNumber, tvControlUrl)); return false; } } /// /// 发送数据 /// internal class IPTVPostData { /// /// 机顶盒序列号 /// public string token { get; set; } /// /// 酒店ID /// public string hotelId { get; set; } /// /// 房间ID /// public string roomId { get; set; } /// /// 用户语句 /// public string value { get; set; } } /// /// 返回 /// internal class IPTVPostDataResult { /// /// 返回码 /// public string retCode { get; set; } /// /// 返回描述 /// public string retMsg { get; set; } } }