SourceCode/jiouosdp/Areas/WeiXinApi/Controllers/ApiController.cs

(开头部分) 10KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Param;
using Wechat;
using Wechat.Enum;
using Wechat.Model;

namespace JiouSDP.Areas.WeiXinApi.Controllers
{
    [LF(IsLoginFilter = false)]
    [PF(IsPermissionFilter = false)]
    public class ApiController : Controller
    {
        public ActionResult callback(string appid)
        {
            //test
            //appid: wx570bc396a51b8ff8
            //Username: gh_3c884a361561
            try
            {
                Wechat.LogManage.Log("公众号消息与事件接收URL->url:" + Request.Url);
                var getpara = GetOrPostParam.GetRequestGet(Request);

                if (Verify(getpara) == true)//验证成功
                {
                    //注意排重的问题,详细见开发文档
                    //.....

                    switch (Request.HttpMethod.ToUpper())
                    {
                        case "GET"://验证URL有效性
                            if (getpara.ContainsKey("echostr") == true)
                            {
                                string echostr = getpara["echostr"];//随机字符串
                                Response.Write(echostr);
                            }
                            break;
                        case "POST":
                            StreamReader stream = new StreamReader(Request.InputStream);
                            string xml = stream.ReadToEnd();
                            Wechat.LogManage.Log("公众号消息与事件接收URL->data:" + xml);
                            LogicalProcessing(xml);
                            break;
                        default:
                            Wechat.LogManage.Log("公众号消息与事件接收URL->HttpMethod::" + Request.HttpMethod.ToUpper());
                            Response.Write("success");
                            break;
                    }
                }
                else
                {
                    Wechat.LogManage.Log("公众号消息与事件接收URL->验证失败");
                }
            }
            catch (Exception ex)
            {
后面还有 186 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。