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.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
2 years ago
|
using DS.Module.Core.Helpers;
|
||
|
|
||
|
namespace DS.Module.Core;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 微信公众号网页开发
|
||
|
/// 参考文档
|
||
|
/// https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
|
||
|
/// </summary>
|
||
|
public class WxWebHelper
|
||
|
{
|
||
|
// static Logger Logger = LogManager.GetCurrentClassLogger();
|
||
|
/// <summary>
|
||
|
/// 获取Token
|
||
|
/// </summary>
|
||
|
/// <param name="appid"></param>
|
||
|
/// <param name="secret"></param>
|
||
|
/// <param name="code"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetAccess_token(string appid, string secret,string code)
|
||
|
{
|
||
|
string strUrl = String.Format(@"https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appid, secret,code);
|
||
|
|
||
|
var result = RequestHelper.Get(strUrl);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 获取公众号用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="Token"></param>
|
||
|
/// <param name="openid"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetUserInfo(string Token, string openid)
|
||
|
{
|
||
|
string url = String.Format(@" https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN", Token, openid);
|
||
|
|
||
|
var result = RequestHelper.Get(url);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
}
|