/// <summary> /// 获取设备ID及二维码 /// </summary> /// <param name="productId">产品ID</param> /// <returns></returns> private GetDeviceRetViewModel CallGetDeviceIdAPI(string productId) { string weiXinToken = WeChatService.GetWeiXinToken(EnumWeChatType.Client.GetHashCode()); var url = string.Format(WeChatConsts.IOT_GET_DEVICE_INFO, weiXinToken); var parms = string.Format("&product_id={0}", productId); var result = NetUtil.ResponseByGet(url, parms); return(JsonConvert.DeserializeObject <GetDeviceRetViewModel>(result.Trim())); }
/// <summary> /// 授权设备 /// </summary> /// <param name="configModel">设备授权信息</param> /// <returns></returns> public AuthDeviceRetViewModel CallAuthDeviceAPI(ConfigDeviceViewModel configModel) { var obj = new AuthDeviceRetViewModel(); string weiXinToken = WeChatService.GetWeiXinToken(EnumWeChatType.Client.GetHashCode()); var url = string.Format(WeChatConsts.IOT_AUTH_DEVICE, weiXinToken); if (configModel != null) { var parms = JsonConvert.SerializeObject(configModel); var result = NetUtil.WechatSendPostRequest(url, parms); obj = JsonConvert.DeserializeObject <AuthDeviceRetViewModel>(result.Trim()); } return(obj); }
/// <summary> /// 设备控制 /// </summary> /// <returns></returns> public BaseRetViewModel SetDevice(DeviceViewModel deviceModel) { BaseRetViewModel retModel = null; string weiXinToken = WeChatService.GetWeiXinToken(EnumWeChatType.Client.GetHashCode()); var url = string.Format(WeChatConsts.IOT_SET_DEVICE, weiXinToken); if (deviceModel != null) { var parms = JsonConvert.SerializeObject(deviceModel); var result = NetUtil.WechatSendPostRequest(url, parms); if (!string.IsNullOrWhiteSpace(result)) { retModel = JsonConvert.DeserializeObject <BaseRetViewModel>(result.Trim()); } } return(retModel); }
/// <summary> /// 设备查询 /// </summary> /// <returns></returns> public BaseRetViewModel GetDevice(DeviceViewModel deviceModel) { BaseRetViewModel retModel = null; string weiXinToken = WeChatService.GetWeiXinToken(EnumWeChatType.Client.GetHashCode()); var url = string.Format(WeChatConsts.IOT_GET_DEVICE, weiXinToken); if (deviceModel != null) { var parms = string.Format("&device_type={0}&device_id={1}&services={2}&user={3}&data={4}", deviceModel.device_type, deviceModel.device_id, deviceModel.services.ToArray().ToString(), deviceModel.data); var result = NetUtil.ResponseByPost(url, parms); if (string.IsNullOrWhiteSpace(result)) { retModel = JsonConvert.DeserializeObject <BaseRetViewModel>(result.Trim()); } } return(retModel); }
/// <summary> /// 获取配置接口参数 /// </summary> /// <param name="apiList">接口列表</param> /// <returns></returns> public WxJsApiConfigViewModel GetJsApiParamsModel(int wxType, string url) { string jsapiTicket = GetWxJsApiTicket(wxType); return(WeChatService.GetSign(wxType, url, jsapiTicket)); }