信鴿推送 .NET (C#) 服務端 SDK rest api 調用庫(v1.2)

信鴿推送 .NET  服務端 SDK rest api 調用庫-介紹

   該版本是基於信鴿推送v2版本的時候封裝的,先拿出來與你們分享,封裝還還湊合,不依賴其餘http調用件,惟一依賴json序列化dll。php

網上有一些封裝的調用庫,可是都不是本身喜歡的調用方式和封裝風格,官方更沒有封裝.NET的版本,只有python、java、php版本,您讓.NET情何以堪啊,java

故我們也來封裝一個.python

舒適提示:該版本是2014-8月份左右封裝的,如今信鴿加了不少功能,可是存在的功能是不影響的,只須要下載源碼,實體類加些參數加幾個調用方法既可。git

 

調用代碼示例

【推送全部設備】github

 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"
                }
            };

            XGResult<XGPushResult> a = qqxg.PushAllDevices(xgp);

 

【單個 Device_token 的手機設備】json

QQXGProvider qqxg = new QQXGProvider();
            XGPushSingleDeviceParam xgp = new XGPushSingleDeviceParam();
            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 = "XGTestSingleDevice",
                Content = "XGTestSingleDevice",
                Vibrate = 1
            };
            xgp.Device_token = "ef8d1c5b866652d14e62bbee2aac3b28b7ed2bf9";
            //POSTopenapi.xg.qq.com/v2/push/all_deviceaccess_id=2100025233timestamp=1399859926valid_time=6006ae193c85570ad1cc8fc9540560093b1
            XGResult<string> a = qqxg.PushSingleDevice(xgp);
單個Device_token設備

【單個帳戶、按標籤推送、獲取消息狀態,獲取應用添加的設備數,查詢標籤,取消定時發送的任務】api

 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);
單個帳戶
 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;
按標籤推送
 QQXGProvider qqxg = new QQXGProvider();
            XGPushGetMsgStatusParam xgp = new XGPushGetMsgStatusParam();
            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.Push_ids = new System.Collections.Generic.List<Push_Id_Obj>();
            xgp.Push_ids.Add(new Push_Id_Obj() { Push_id = "152947" });
            xgp.Push_ids.Add(new Push_Id_Obj() { Push_id = "152944" });
            xgp.Push_ids.Add(new Push_Id_Obj() { Push_id = "139303" });
            XGResult<XGGetMsgStatusResult> a = qqxg.PushGetMsgStatus(xgp);
獲取消息狀態
QQXGProvider qqxg = new QQXGProvider("application");
            XGPushGetAppDeviceNumParam xgp = new XGPushGetAppDeviceNumParam();
            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";
            XGResult<XGDeviceNumResult> a = qqxg.GetAppDeviceNum(xgp);
應用添加的設備數
QQXGProvider qqxg = new QQXGProvider("tags");
            XGPushQueryAppTagsParam xgp = new XGPushQueryAppTagsParam();
            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";

            XGResult<XGQueryAppTagsResult> a = qqxg.QueryAppTags(xgp);
查詢標籤
QQXGProvider qqxg = new QQXGProvider();
            XGOtherCommonParam xgp = new XGOtherCommonParam();
            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.Push_id = "139303";
            XGResult<XGStatusResult> a = qqxg.PushCancelTimingTask(xgp);
取消定時發送的任務

 

開源代碼地址

 信鴿推送.NET庫GitHub首頁app

https://github.com/jasnature/NSTool.XGPush 源碼對你有幫助的話,請給星星喲。ide

相關文章
相關標籤/搜索