コード例 #1
0
ファイル: QQXGUnit.cs プロジェクト: xiubjarne/NSTool.XGPush
        public void XGTestSingleAccount()
        {
            QQXGProvider             qqxg = new QQXGProvider();
            XGPushSingleAccountParam xgp  = new XGPushSingleAccountParam();

            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   = "XGTestSingleAccount",
                Content = "XGTestSingleAccount",
                Vibrate = 1,
                Ring    = 1
            };
            xgp.Account = "ffff";
            //POSTopenapi.xg.qq.com/v2/push/all_deviceaccess_id=2100025233timestamp=1399859926valid_time=6006ae193c85570ad1cc8fc9540560093b1
            XGResult <string> a = qqxg.PushSingleAccount(xgp);
        }
コード例 #2
0
        /// <summary>
        /// PUSH消息给单个账户或别名
        /// </summary>
        /// <param name="saParm"></param>
        /// <returns></returns>
        public XGResult <string> PushSingleAccount(XGPushSingleAccountParam saParm)
        {
            if (string.IsNullOrEmpty(saParm.Account))
            {
                throw new ArgumentException("saParm.Account参数不能为空!");
            }
            ParamBaseValidata(saParm);
            PushParamBaseValidata(saParm);
            ParamBaseCreate(saParm, XGMethod.single_account);

            string pushSingleAccountUrl = string.Format("{0}/{1}", apiFullUrl, XGMethod.single_account.ToString());
            string postData             = CreateXGParamPostStr <XGPushSingleAccountParam>(saParm, "&");

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

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

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