You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BP.Cloud.WeXinAPI;
namespace CCFlow.Admin.WeChat
{
public partial class CheckHost : System.Web.UI.Page
{
/// <summary>
/// 用来效验服务器与腾讯是否可以连接.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
//构造函数.
Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(Glo.Token,
Glo.EncodingAESKey, Glo.CorpID);
//sxx
string sVerifyMsgSig = HttpUtility.UrlDecode(this.Request["msg_signature"] ?? string.Empty);
string sVerifyTimeStamp = HttpUtility.UrlDecode(this.Request["timestamp"] ?? string.Empty);
string sVerifyNonce = HttpUtility.UrlDecode(this.Request["nonce"] ?? string.Empty);
string sVerifyEchoStr = HttpUtility.UrlDecode(this.Request["echostr"] ?? string.Empty).Replace(" ", "+");
//验证回调URL
if (!string.IsNullOrEmpty(sVerifyEchoStr))
{
int ret = 0;
string sEchoStr = string.Empty;
ret = wxcpt.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp, sVerifyNonce,
sVerifyEchoStr, ref sEchoStr);
if (ret != 0)
{
this.Response.Write("ERR: VerifyURL fail, ret: " + ret);
return;
//System.Console.WriteLine();
}
//ret==0表示验证成功sEchoStr参数表示明文用户需要将sEchoStr作为get请求的返回参数返回给企业微信。
//this.Response.Write(sEchoStr);
this.Response.Write(sEchoStr);
this.Response.End();
}
}
}
}