Пример #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);
        }
Пример #2
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);
        }
Пример #3
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 WxJsonResult BindPage(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                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);
            }, accessTokenOrAppId));
        }
Пример #4
0
        public bool SetRelationship(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType type)
        {
            WxJsonResult wxJsonResult = ShakeAroundApi.BindPage(_accessToken, deviceIdentifier, pageIds, type, ShakeAroundAppendType.新增, 10000);

            if (wxJsonResult.errcode != ReturnCode.请求成功)
            {
                throw new Exception(wxJsonResult.errmsg);
            }
            return(true);
        }
Пример #5
0
 public static WxJsonResult BindPage(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType)
 {
     return(ShakeAroundApi.BindPage(WXStoreHelper.siteSettings.WeixinAppId, deviceIdentifier, pageIds, bindType, appendType, 10000));
 }
Пример #6
0
        public bool SetRelationship(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType type)
        {
            var result = ShakeAroundApi.BindPage(this._accessToken, deviceIdentifier, pageIds, type, ShakeAroundAppendType.新增);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            return(true);
        }