changhong_newclient/wb_unity_pro/Assets/Scripts/Platform/WXData.cs

85 lines
2.1 KiB
C#
Raw Normal View History

using UnityEngine;
using System.Collections;
public static class WXData
{
2025-09-12 23:04:24 +08:00
private static string _appId = "wx12345678";
private static string _appSecret = "2sfas2435gt574gfdw357";
static string _accessToken;
static string _refreshToken;
static string _openid;
2025-09-12 23:04:24 +08:00
public static void SetAppInfo(string id,string scret)
{
_appId = id;
_appSecret = scret;
}
//-------------------------------------------------------------
public static string GetApplyTokenURL(string code)
{
return string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", _appId, _appSecret, code);
}
//-------------------------------------------------------------
public static string GetCheckTokenURL()
{
return string.Format("https://api.weixin.qq.com/sns/auth?access_token={0}&openid={1}", _accessToken, _openid);
}
//-------------------------------------------------------------
public static string GetRefreshTokenURL()
{
return string.Format("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", _appId, _refreshToken);
}
//-------------------------------------------------------------
public static string GetUserInfoURL()
{
return string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", _accessToken, _openid);
}
//-------------------------------------------------------------
public static string RefreshToken
{
set
{
_refreshToken = value;
}
get
{
return _refreshToken;
}
}
//-------------------------------------------------------------
public static string AccessToken
{
set
{
_accessToken = value;
}
get
{
return _accessToken;
}
}
public static string OpenID
{
set
{
_openid = value;
}
get
{
return _openid;
}
}
}