Exemplo n.º 1
0
        private string client_OnUserFollow(object sender, EventArgs e)
        {
            NameValueCollection param = new NameValueCollection
            {
                HttpContext.Current.Request.Form,
                HttpContext.Current.Request.QueryString
            };

            try
            {
                AlipayOHClient alipayOHClient = (AlipayOHClient)sender;
                SiteSettings   masterSettings = SettingsManager.GetMasterSettings();
                Articles       articles       = new Articles
                {
                    Item = new Item
                    {
                        Description = masterSettings.AliOHFollowRelay,
                        Title       = (string.IsNullOrWhiteSpace(masterSettings.AliOHFollowRelayTitle) ? "欢迎您的关注!" : masterSettings.AliOHFollowRelayTitle)
                    }
                };
                IRequest            request             = new MessagePushRequest(alipayOHClient.request.AppId, alipayOHClient.request.FromUserId, articles, 1, null, "image-text");
                AlipayOHClient      alipayOHClient2     = new AlipayOHClient(masterSettings.AliOHServerUrl, alipayOHClient.request.AppId, this.alipayPubKeyFile, this.priKeyFile, this.pubKeyFile, "UTF-8");
                MessagePushResponse messagePushResponse = alipayOHClient2.Execute <MessagePushResponse>(request);
            }
            catch (Exception ex)
            {
                Globals.WriteExceptionLog_Page(ex, param, "alipay.ashx");
            }
            return("");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Push Message Broadcast (to all users)
        /// </summary>
        /// <param name="request">Push request parameter</param>
        /// <returns></returns>
        public MessagePushResponse PushMessageBroadcast(MessagePushBroadcastRequest request)
        {
            var postStr = request.GeneratePostData(Apikey, SecretKey);

            var response = PostData(request.ServiceUrl, postStr);

            if (response == null)
            {
                return(null);
            }

            MessagePushResponse result = null;

            try
            {
                result = JsonConvert.DeserializeObject <MessagePushResponse>(response);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("PushMessageBroadcast Error Response Deserialize Fail, May not valid json:" + ex.Message + " " + response);
            }
            return(result);
        }