If
e.host =
"weixin.foxtable.com"
Then '需要授权才能访问的域名
Dim OpenID
As String
Dim sb
As New
StringBuilder
sb.AppendLine("<meta
name='viewport' c>")
If e.GetValues.ContainsKey("code")
Then '如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的OpenID
Dim
ul As
String = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code"
ul =
CExp(ul,"wx8acdb7df5beb68fd","a5a3b06a790d4200a151e6b13c3dc263",e.GetValues("code"))
Dim hc
As new
HttpClient(ul)
Dim jo
As JObject =
JObject.Parse(hc.GetData)
If jo("openid")
IsNot Nothing
Then
OpenID =
jo("openid")
e.AppendCookie("openid",OpenID)
'将openid存储在Cookie中
End If
Else
OpenId =
e.Cookies("openid")
'否则从cookie中提取openid
End If
这段里 e.GetValues.ContainsKey("code") = false e.Cookies("openid")
' = "" 空 这个怎么解决啊
|