Beispiel #1
0
        /// <summary>
        /// 当用户关注公众号时,进行的操作
        /// </summary>
        /// <param name="openid"></param>
        /// <returns></returns>
        private static void SubscribeEvent(Dictionary <string, string> dict, ref string result)
        {
            try
            {
                string openid = dict["FromUserName"];
                //关注时发送的消息
                ReplayTextMessage message = new ReplayTextMessage()
                {
                    ToUserName   = dict["FromUserName"],
                    FromUserName = dict["ToUserName"],
                    CreateTime   = Common.GetTimeStamp(),
                    Content      = "您好,欢迎关注微信公众号-测试号!"
                };
                result = message.ToXml();
                Log.WriteLog("用户:" + dict["FromUserName"] + " 关注了公众号 。时间:" + message.CreateTime);

                /*
                 * //存储用户信息
                 *
                 * */
            }
            catch (Exception ex)
            {
                //WeLogger.Error("用户关注事件,操数据库失败,错误消息:" + ex.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 自动回复文本消息
        /// </summary>
        /// <param name="dict"></param>
        /// <param name="result"></param>
        private static void TextMessageHandler(Dictionary <string, string> dict, ref string result)
        {
            string returnMeg = "您好!感谢发送消息。公众号还在测试中。";

            ReplayTextMessage message = new ReplayTextMessage()
            {
                ToUserName   = dict["FromUserName"],
                FromUserName = dict["ToUserName"],
                CreateTime   = Common.GetTimeStamp(),
                Content      = returnMeg
            };

            result = message.ToXml();
            Log.WriteLog("用户:" + dict["FromUserName"] + " 回复消息:" + dict["Content"] + " 时间:" + message.CreateTime);
        }