Ejemplo n.º 1
0
        /// <summary>
        /// 配置设备与页面的关联关系
        /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="deviceIdentifier"></param>
        /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
        /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
        /// <param name="pageIds"></param>
        /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
        /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static WxJsonResult BindPage(string accessToken, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
        {
            var url = string.Format("https://api.weixin.qq.com/shakearound/device/bindpage?access_token={0}", accessToken);

            var data = new
            {
                device_identifier = deviceIdentifier,
                page_ids = pageIds,
                bind = (int)bindType,
                append = (int)appendType
            };

            return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 配置设备与页面的关联关系
        /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="deviceIdentifier"></param>
        /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
        /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
        /// <param name="pageIds"></param>
        /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
        /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static WxJsonResult BindPage(string accessToken, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
        {
            var url = string.Format("https://api.weixin.qq.com/shakearound/device/bindpage?access_token={0}", accessToken);

            var data = new
            {
                device_identifier = deviceIdentifier,
                page_ids          = pageIds,
                bind   = (int)bindType,
                append = (int)appendType
            };

            return(CommonJsonSend.Send <WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 以设备为维度的数据统计接口
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="deviceIdentifier">指定页面的设备ID</param>
        /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
        /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
        /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
        /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static StatisticsResultJson StatisticsByDevice(string accessToken,
                                                              DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
                                                              int timeOut = Config.TIME_OUT)
        {
            var url = string.Format("https://api.weixin.qq.com/shakearound/statistics/device?access_token={0}",
                                    accessToken);

            var data = new
            {
                device_identifier = deviceIdentifier,
                begin_date        = beginDate,
                end_date          = endDate
            };

            return(CommonJsonSend.Send <StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 从分组中移除设备
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="groupId">分组唯一标识,全局唯一</param>
        /// <param name="deviceIdentifier">分组列表的起始索引值</param>

        /// <returns></returns>
        public static RegisterResultJson GroupDeleteDevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
                var data = new object();
                if (!deviceIdentifier.device_id.HasValue)
                {
                    data = new
                    {
                        group_id = groupId,
                        uuid = deviceIdentifier.uuid,
                        major = deviceIdentifier.major,
                        minor = deviceIdentifier.minor

                    };
                }
                else
                {
                    data = new
                    {
                        group_id = groupId,
                        device_id = deviceIdentifier.device_id.Value
                    };
                }


                return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);

            }, accessTokenOrAppId);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加设备到分组
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="groupId">分组唯一标识,全局唯一</param>
        /// <param name="deviceIdentifier">分组列表的起始索引值</param>

        /// <returns></returns>
        public static RegisterResultJson GroupGetAdddevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
                object data = null;
                if (string.IsNullOrEmpty(((long)deviceIdentifier.device_id).ToString()))
                {
                    data = new
                    {
                        group_id = groupId,
                        uuid = deviceIdentifier.uuid,
                        major = deviceIdentifier.major,
                        minor = deviceIdentifier.minor

                    };
                }
                else
                {
                    data = new
                    {
                        group_id = groupId,
                        device_id = deviceIdentifier.device_id
                    };
                }

                return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);

            }, accessTokenOrAppId);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 以设备为维度的数据统计接口
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="deviceIdentifier">指定页面的设备ID</param>
        /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
        /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
        /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
        /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static StatisticsResultJson StatisticsByDevice(string accessTokenOrAppId,
            DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
            int timeOut = Config.TIME_OUT)
        {
            return ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    device_identifier = deviceIdentifier,
                    begin_date = beginDate,
                    end_date = endDate
                };

                return CommonJsonSend.Send<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);

            }, accessTokenOrAppId);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///  查询设备的关联关系
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="deviceIdentifier">指定的设备</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    type = 1,
                    device_identifier = deviceIdentifier
                };

                return CommonJsonSend.Send<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);

            }, accessTokenOrAppId);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 【异步方法】配置设备与页面的关联关系
        /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="deviceIdentifier"></param>
        /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
        /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
        /// <param name="pageIds"></param>
        /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
        /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task<WxJsonResult> BindPageAsync(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
        {
            return await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/bindpage?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    device_identifier = deviceIdentifier,
                    page_ids = pageIds,
                    bind = (int)bindType,
                    append = (int)appendType
                };

                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);

            }, accessTokenOrAppId);
        }
Ejemplo n.º 9
0
        public static Senparc.Weixin.MP.AdvancedAPIs.ShakeAround.RelationResult SearchPagesByDeviceId(string accessTokenOrAppId, int type, DeviceApply_Data_Device_Identifiers deviceIdentifiers, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var data = new
                {
                    type = type,
                    device_identifier = deviceIdentifiers
                };

                return CommonJsonSend.Send <Senparc.Weixin.MP.AdvancedAPIs.ShakeAround.RelationResult>(accessToken, "https://api.weixin.qq.com/shakearound/relation/search?access_token={0}", data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }