Example #1
0
        public void XGTestAllDevice()
        {
            QQXGProvider         qqxg = new QQXGProvider();
            XGPushAllDeviceParam xgp  = new XGPushAllDeviceParam();

            xgp.Timestamp  = null; //1299865775;
            xgp.Valid_time = 600;  //600;
            xgp.Sign       = null;
            //实际key请使用实际的,下面仅演示作用
            //============测试key1==============
            xgp.Access_id = 2100025233;
            //xgp.Access_Key = "ARQ4CB14Q92X";
            xgp.Secret_Key = "6ae193c85570ad1cc8fc9540560093b1";
            //============测试key2==============
            //xgp.Access_id = 2100025346;
            //xgp.Access_Key = "AUP1I5W741WJ";
            //xgp.Secret_Key = "f2391810bc98c0d7435ec7c96b8f524f";
            xgp.Message_type = 1;
            xgp.Expire_time  = 3600;
            xgp.Message      = new NotifyMessage()
            {
                Custom_content = new  SerializableDictionary <string, string>()
                {
                    { "type", "123" }, { "type1", "456" }
                },
                //Accept_time = new System.Collections.Generic.List<AcceptTime>(){
                //  new AcceptTime(){ Start=new XGTime(){ Hour="18", Min="02"}, End=new XGTime(){ Hour="18", Min="30"}}
                //},
                Clearable = 1,
                Title     = "XGTestAllDevice-50%",
                Content   = "有中文10%,人们有1%以及,$abcdef", //中文测试
                Vibrate   = 1,
                Ring      = 1,
                Action    = new NotifyMessageAction()
                {
                    Action_type = 2,
                    Browser     = new NotifyMessageAction_Browser()
                    {
                        Url     = "http://baidu.com",
                        Confirm = 0
                    },
                    Intent   = "http://baidu.com",
                    Activity = "XGPushDemo"
                }
            };
            //xgp.Send_time = DateTime.Now.AddMinutes(2).ToString("yyyy-MM-dd HH:mm:ss");

            //POSTopenapi.xg.qq.com/v2/push/all_deviceaccess_id=2100025233timestamp=1399859926valid_time=6006ae193c85570ad1cc8fc9540560093b1
            //string xml = SerializeToXML<XGPushAllDeviceParam>(xgp);
            //XGPushAllDeviceParam t = DeSerializeXML<XGPushAllDeviceParam>(xml);
            XGResult <XGPushResult> a = qqxg.PushAllDevices(xgp);
            //Console.WriteLine(xml);
            //Console.WriteLine(t.ToString());
        }
Example #2
0
        /// <summary>
        /// PUSH消息到所有设备
        /// </summary>
        /// <param name="adParm"></param>
        /// <returns></returns>
        public XGResult <XGPushResult> PushAllDevices(XGPushAllDeviceParam adParm)
        {
            ParamBaseValidata(adParm);
            PushParamBaseValidata(adParm);
            ParamBaseCreate(adParm, XGMethod.all_device);
            string pushAllDeviceUrl = string.Format("{0}/{1}", apiFullUrl, XGMethod.all_device.ToString());
            string postData         = CreateXGParamPostStr <XGPushAllDeviceParam>(adParm, "&");

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

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

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