|
|
|
@ -11,12 +11,12 @@ namespace BWP.B3WeChat.Utils |
|
|
|
{ |
|
|
|
public static class WeChatPageUtil |
|
|
|
{ |
|
|
|
const string template = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={APPID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=snsapi_base&state={STAT}&connect_redirect=1#wechat_redirect"; |
|
|
|
const string template = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={APPID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=snsapi_base&state={STATE}#wechat_redirect"; |
|
|
|
public static string GetWeChatUrl(string url,string state="1") |
|
|
|
{ |
|
|
|
|
|
|
|
var config = new B3WeChatConfig(); |
|
|
|
var result = template.Replace("{APPID}", config.AppID) |
|
|
|
var result = template.Replace("{APPID}", config.AppID.Value) |
|
|
|
.Replace("{REDIRECT_URI}", HttpUtility.UrlEncode(url)) |
|
|
|
.Replace("{STATE}", state); |
|
|
|
return result; |
|
|
|
@ -27,8 +27,8 @@ namespace BWP.B3WeChat.Utils |
|
|
|
public static string QueryOpenID(string code) |
|
|
|
{ |
|
|
|
var config = new B3WeChatConfig(); |
|
|
|
var url = getAccessTokenTemplate.Replace("{APPID", config.AppID) |
|
|
|
.Replace("{SECRET}", config.AppSecret) |
|
|
|
var url = getAccessTokenTemplate.Replace("{APPID}", config.AppID.Value) |
|
|
|
.Replace("{SECRET}", config.AppSecret.Value) |
|
|
|
.Replace("{CODE}", code); |
|
|
|
|
|
|
|
var json = new WebClient() { Encoding = Encoding.UTF8 }.DownloadString(url); |
|
|
|
|