예제 #1
0
        public void XGTestTagsDevice()
        {
            QQXGProvider          qqxg = new QQXGProvider();
            XGPushTagsDeviceParam xgp  = new XGPushTagsDeviceParam();

            xgp.Timestamp  = null;
            xgp.Valid_time = 600; //600;
            xgp.Sign       = null;
            //============测试DEMO==============
            //xgp.Access_id = 2100025233;
            //xgp.Access_Key = "ARQ4CB14Q92X";
            //xgp.Secret_Key = "6ae193c85570ad1cc8fc9540560093b1";
            //============测试DEMO==============
            xgp.Access_id = 2100025346;
            //xgp.Access_Key = "AUP1I5W741WJ";
            xgp.Secret_Key   = "f2391810bc98c0d7435ec7c96b8f524f";
            xgp.Message_type = 1;
            xgp.Message      = new NotifyMessage()
            {
                Title   = "XGTestTagsDevice",
                Content = "XGTestTagsDevice",
                Vibrate = 1,
                Ring    = 1
            };
            xgp.Tags_list = new System.Collections.Generic.List <string>();
            xgp.Tags_list.Add("nature");
            xgp.Tags_op = "OR";
            //POSTopenapi.xg.qq.com/v2/push/all_deviceaccess_id=2100025233timestamp=1399859926valid_time=6006ae193c85570ad1cc8fc9540560093b1
            XGResult <XGPushResult> a = qqxg.PushTagsDevice(xgp);
            string a1 = a.Err_msg;
        }
예제 #2
0
        /// <summary>
        /// PUSH消息给tags指定的设备
        /// </summary>
        /// <param name="tdParm"></param>
        /// <returns></returns>
        public XGResult <XGPushResult> PushTagsDevice(XGPushTagsDeviceParam tdParm)
        {
            if (tdParm.Tags_list == null || tdParm.Tags_list.Count <= 0)
            {
                throw new ArgumentException("tdParm.Tags_list参数不能为空!或者个数不能为零。");
            }
            if (string.IsNullOrEmpty(tdParm.Tags_op))
            {
                throw new ArgumentException("tdParm.Tags_op参数不能为空!");
            }
            if (!tdParm.Tags_op.Equals("AND") && !tdParm.Tags_op.Equals("OR"))
            {
                throw new ArgumentException("tdParm.Tags_op参数只能为(AND,OR)2个参数之一!");
            }
            ParamBaseValidata(tdParm);
            PushParamBaseValidata(tdParm);
            ParamBaseCreate(tdParm, XGMethod.tags_device);
            string pushTagsDeviceUrl = string.Format("{0}/{1}", apiFullUrl, XGMethod.tags_device.ToString());
            string postData          = CreateXGParamPostStr <XGPushTagsDeviceParam>(tdParm, "&");

            System.Diagnostics.Trace.Write("\r\n===postData的值:" + postData);

            string result = httpClient.Post(pushTagsDeviceUrl, postData);

            System.Diagnostics.Trace.Write("\r\n===返回result的值:" + result);
            return(JsonHelper.FromJson <XGResult <XGPushResult> >(result));
        }