微信公众平台开发配置(用新花生壳映射到本地)

第一步:

  利用新花生壳,映射一个外网地址为80端口的域名,内网映射到自己本地的IIS下(或者其它IIS也行)。如图:

  

第二步:

  在本地的IIS根目录下添加用于接收微信服务的一般处理事项文件(.ashx),在文件内写入如下代码:

 

 string token = "微信配置时的Token";
        if (string.IsNullOrEmpty(token))
        {
            return;
        }

        string echoString = HttpContext.Current.Request.QueryString["echoStr"];
        string signature = HttpContext.Current.Request.QueryString["signature"];
        string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
        string nonce = HttpContext.Current.Request.QueryString["nonce"];

        if (!string.IsNullOrEmpty(echoString))
        {
            HttpContext.Current.Response.Write(echoString);
            HttpContext.Current.Response.End();
        }  

第三步:

  在微信公众平台上保存该http路径,如图:

  

配置完成,下面就可以开发自己的程序了。

posted @ 2015-03-07 10:26  聆听的风声  阅读(1036)  评论(0)    收藏  举报