C# Class Senparc.Weixin.Open.QRConnect.QRConnectAPI

代公众号发起网页授权
显示文件 Open project: JeffreySu/WeiXinMPSDK

Public Methods

Method Description
Auth ( string accessToken, string openId ) : WxJsonResult

检验授权凭证(access_token)是否有效

AuthAsync ( string accessToken, string openId ) : Task

【异步方法】检验授权凭证(access_token)是否有效

GetAccessToken ( string appId, string appSecret, string code, string grantType = "authorization_code" ) : QRConnectAccessTokenResult

获取AccessToken

GetAccessTokenAsync ( string appId, string appSecret, string code, string grantType = "authorization_code" ) : Task

【异步方法】获取AccessToken

GetQRConnectUrl ( string appId, string redirectUrl, string state, OAuthScope scopes, string responseType = "code" ) : string

微信扫码登录网页授权

GetUserInfo ( string accessToken, string openId ) : QRConnectUserInfo

获取用户基本信息

GetUserInfoAsync ( string accessToken, string openId ) : Task

【异步方法】获取用户基本信息

RefreshToken ( string appId, string refreshToken, string grantType = "refresh_token" ) : RefreshAccessTokenResult

刷新access_token(如果需要)

RefreshTokenAsync ( string appId, string refreshToken, string grantType = "refresh_token" ) : Task

【异步方法】刷新access_token(如果需要)

Method Details

Auth() public static method

检验授权凭证(access_token)是否有效
public static Auth ( string accessToken, string openId ) : WxJsonResult
accessToken string
openId string 用户的唯一标识
return Senparc.Weixin.Entities.WxJsonResult

AuthAsync() public static method

【异步方法】检验授权凭证(access_token)是否有效
public static AuthAsync ( string accessToken, string openId ) : Task
accessToken string
openId string 用户的唯一标识
return Task

GetAccessToken() public static method

获取AccessToken
public static GetAccessToken ( string appId, string appSecret, string code, string grantType = "authorization_code" ) : QRConnectAccessTokenResult
appId string 应用唯一标识,在微信开放平台提交应用审核通过后获得
appSecret string 应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
code string GetQRConnectUrl()接口返回的code
grantType string 填authorization_code
return QRConnectAccessTokenResult

GetAccessTokenAsync() public static method

【异步方法】获取AccessToken
public static GetAccessTokenAsync ( string appId, string appSecret, string code, string grantType = "authorization_code" ) : Task
appId string 应用唯一标识,在微信开放平台提交应用审核通过后获得
appSecret string 应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
code string GetQRConnectUrl()接口返回的code
grantType string 填authorization_code
return Task

GetQRConnectUrl() public static method

微信扫码登录网页授权
public static GetQRConnectUrl ( string appId, string redirectUrl, string state, OAuthScope scopes, string responseType = "code" ) : string
appId string 第三方应用唯一标识
redirectUrl string 重定向地址,需要进行UrlEncode
state string 用于保持请求和回调的状态,授权请求后原样带回给第三方。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议第三方带上该参数,可设置为简单的随机数加session进行校验
scopes OAuthScope 应用授权作用域,拥有多个作用域用逗号(,)分隔,网页应用目前仅填写snsapi_login即可
responseType string 填code
return string

GetUserInfo() public static method

获取用户基本信息
public static GetUserInfo ( string accessToken, string openId ) : QRConnectUserInfo
accessToken string 调用接口凭证
openId string 普通用户的标识,对当前公众号唯一
return QRConnectUserInfo

GetUserInfoAsync() public static method

【异步方法】获取用户基本信息
public static GetUserInfoAsync ( string accessToken, string openId ) : Task
accessToken string 调用接口凭证
openId string 普通用户的标识,对当前公众号唯一
return Task

RefreshToken() public static method

刷新access_token(如果需要)
public static RefreshToken ( string appId, string refreshToken, string grantType = "refresh_token" ) : RefreshAccessTokenResult
appId string 第三方应用唯一标识
refreshToken string 填写通过access_token获取到的refresh_token参数
grantType string 填refresh_token
return RefreshAccessTokenResult

RefreshTokenAsync() public static method

【异步方法】刷新access_token(如果需要)
public static RefreshTokenAsync ( string appId, string refreshToken, string grantType = "refresh_token" ) : Task
appId string 第三方应用唯一标识
refreshToken string 填写通过access_token获取到的refresh_token参数
grantType string 填refresh_token
return Task