JumboTCMS_src/JumboTCMS.OAuth2/OAuths/WeixinOAuth.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
namespace JumboTCMS.OAuth2
{
public class WeixinOAuth : OAuth2Base
{
internal override OAuthServer server
{
get
{
return OAuthServer.Weixin;
}
}
internal override string OAuthUrl
{
get
{
return "https://open.weixin.qq.com/connect/qrconnect?appid={0}&scope=snsapi_login&redirect_uri={1}&state={2}";
}
}
internal override string TokenUrl
{
get
{
return "https://api.weixin.qq.com/sns/oauth2/access_token";
}
}
internal string UserInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}";
public override string GetAuthorizeURL()
{
return string.Format(OAuthUrl, AppKey, System.Web.HttpUtility.UrlEncode(CallbackUrl), "Weixin");
}
public override bool Authorize()
{
if (!string.IsNullOrEmpty(code))
{
string result = GetToken("GET", "Weixin");//一次性返回数据,QQ仅返回Token,还需要一次请求获取OpenID。//access_token=A5E175586196173434374BD3DBBAA5E8A3&expires_in=7776000
//分解result;
if (!string.IsNullOrEmpty(result))
{
try
{
token = Tool.GetJosnValue(result, "access_token");
if (!string.IsNullOrEmpty(token))
{
double d = 0;
if (double.TryParse(Tool.GetJosnValue(result, "expires_in"), out d))
{
expiresTime = DateTime.Now.AddSeconds(d);
}
openID = Tool.GetJosnValue(result, "openid");
if (!string.IsNullOrEmpty(openID))
{
//读取QQ账号和头像
result = wc.DownloadString(string.Format(UserInfoUrl, token, openID));
if (!string.IsNullOrEmpty(result)) //返回:callback( {"client_id":"YOUR_APPID","openid":"YOUR_OPENID"} );
后面还有 22 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。