protected void BtnSend_Click(object sender, EventArgs e)
        {
            try
            {
                string sk = TBSK.Text;
                string ak = TBAK.Text;


                BaiduPush Bpush  = new BaiduPush("POST", sk);
                String    apiKey = ak;
                String    messages;
                String    method   = "push_msg";
                TimeSpan  ts       = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                uint      unixTime = (uint)ts.TotalSeconds;

                uint   message_type;
                string messageksy = "xxxxxx";
                if (RbMessage.Checked)
                {
                    message_type = 0;
                    messages     = TBMessage.Text;
                }
                else
                {
                    message_type = 1;
                    BaiduPushNotification notification = new BaiduPushNotification();
                    notification.title       = TBTitle.Text;
                    notification.description = TBDescription.Text;
                    messages = notification.getJsonString().Replace("\"", "'");
                }


                PushOptions pOpts;
                if (RBUnicast.Checked)
                {
                    pOpts = new PushOptions(method, apiKey, TBUserId.Text, TBChannelID.Text, messages, messageksy, unixTime);
                }
                else if (RBMulticast.Checked)
                {
                    pOpts = new PushOptions(method, apiKey, TBTag.Text, messages, messageksy, unixTime);
                }
                else
                {
                    pOpts = new PushOptions(method, apiKey, messages, messageksy, unixTime);
                }

                pOpts.message_type = message_type;

                string response = Bpush.PushMessage(pOpts);

                TextBoxResponse.Text = response;
            }
            catch (Exception ex)
            {
                TextBoxResponse.Text = "Exception caught sending update: " + ex.ToString();
            }
        }
Ejemplo n.º 2
0
        protected void BtnSend_Click(object sender, EventArgs e)
        {
            try
            {
                string sk = TBSK.Text;
                string ak = TBAK.Text;

                BaiduPush Bpush = new BaiduPush("POST", sk);
                String apiKey = ak;
                String messages;
                String method = "push_msg";
                TimeSpan ts = (DateTime.UtcNow - new DateTime(1970,1,1,0,0,0));
                uint unixTime = (uint)ts.TotalSeconds;

                uint message_type;
                string messageksy="xxxxxx";
                if (RbMessage.Checked)
                {
                    message_type = 0;
                    messages = TBMessage.Text;
                }
                else
                {
                    message_type = 1;
                    BaiduPushNotification notification=new BaiduPushNotification();
                    notification.title = TBTitle.Text;
                    notification.description = TBDescription.Text;
                    messages =notification.getJsonString().Replace("\"", "'");

                }

                PushOptions pOpts;
                if(RBUnicast.Checked)
                {
                    pOpts = new PushOptions(method, apiKey, TBUserId.Text, TBChannelID.Text, messages, messageksy, unixTime);
                }else if(RBMulticast.Checked)
                {
                    pOpts = new PushOptions(method, apiKey, TBTag.Text, messages, messageksy, unixTime);
                }else
                {
                    pOpts = new PushOptions(method, apiKey, messages, messageksy, unixTime);
                }

                pOpts.message_type = message_type;

                string response= Bpush.PushMessage(pOpts);

                TextBoxResponse.Text = response;

            }
            catch (Exception ex)
            {
                TextBoxResponse.Text = "Exception caught sending update: " + ex.ToString();
            }
        }