65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Common
|
|
{
|
|
/// <summary>
|
|
/// 若琪对接
|
|
/// </summary>
|
|
public static class RokidOperation
|
|
{
|
|
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(RokidOperation));
|
|
//private static string rokid_url = "https://homebase.rokid.com/trigger/with/4GoVytuQZ";
|
|
/// <summary>
|
|
/// 通知若琪播报欢迎词
|
|
/// </summary>
|
|
/// <param name="hotelName"></param>
|
|
/// <param name="roomNumber"></param>
|
|
/// <param name="webhookUrl"></param>
|
|
/// <param name="message"></param>
|
|
public static void UploadWebhook(string hotelName, string roomNumber, string webhookUrl, string message)
|
|
{
|
|
if (!string.IsNullOrEmpty(webhookUrl) && !string.IsNullOrEmpty(message))
|
|
{
|
|
RokidWebhook postData = new RokidWebhook()
|
|
{
|
|
type = "tts",
|
|
devices = new DeviceQuery() { roomName = roomNumber },
|
|
data = new RokidObject() { text = message }
|
|
};
|
|
try
|
|
{
|
|
string param = Newtonsoft.Json.JsonConvert.SerializeObject(postData);
|
|
string result = HttpWebRequestHelper.PostWebRequest(webhookUrl, param);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(string.Format("酒店({0})客房({1})调用若琪接口({2})失败:{3}", hotelName, roomNumber, webhookUrl, ex));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class RokidWebhook
|
|
{
|
|
public string type { get; set; }
|
|
public DeviceQuery devices { get; set; }
|
|
public RokidObject data { get; set; }
|
|
}
|
|
|
|
internal class DeviceQuery
|
|
{
|
|
//public string sn { get; set; }
|
|
public string roomName { get; set; }
|
|
//public string tag { get; set; }
|
|
//public bool isAll { get; set; }
|
|
}
|
|
|
|
internal class RokidObject
|
|
{
|
|
public string text { get; set; }
|
|
}
|
|
}
|