public static MainButton GetMenu(string accessToken) { var url = WxUrl.GetMenu.ToFormat(accessToken); try { return(WxHttp.Get <FullButtonGroupMenu>(url).ToMainButton()); } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("WeiXinBase", ex); return(null); } }
public static bool DeleteMenu(string companyId, string accessToken) { ResError result = WxHttp.Get(WxUrl.DeleteMenu.ToFormat(accessToken)); if (result.errcode == ResCode.请求成功) { return(true); } if (result.errcode == ResCode.获取accessToken时AppSecret错误或者accessToken无效) { WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(companyId); var newAccessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret, true); ResError newResult = WxHttp.Get(WxUrl.DeleteMenu.ToFormat(newAccessToken)); return(newResult.errcode == ResCode.请求成功); } return(false); }
/// <summary> /// 获取凭证接口 /// </summary> /// <param name="grantType">获取access_token填写client_credential</param> /// <param name="appid">第三方用户唯一凭证</param> /// <param name="secret">第三方用户唯一凭证密钥,既appsecret</param> /// <returns></returns> public static AccessToken GetToken(string appid, string secret, string grantType = "client_credential") { var url = WxUrl.GetAccessToken.ToFormat(grantType, appid, secret); return(WxHttp.Get <AccessToken>(url)); }
/// <summary> /// 获取JsapiTicket /// </summary> public static JsapiTicket GetTicket(string accesstoken) { var url = WxUrl.GetTicket.ToFormat(accesstoken, DateTime.Now.Ticks); return(WxHttp.Get <JsapiTicket>(url)); }
/// <summary> /// 取帐号的关注者列表 /// </summary> /// <param name="accessToken"></param> /// <param name="nextOpenId"></param> /// <returns></returns> public static UserGet GetUserList(string accessToken, string nextOpenId) { var url = WxUrl.GetUsers.ToFormat(accessToken, nextOpenId); return(WxHttp.Get <UserGet>(url)); }
/// <summary> /// 获取JsapiTicket /// </summary> public static JsapiTicket GetTicket(AccessToken token) { var url = WxUrl.UpdateUserGroup.ToFormat(token.Accesstoken, DateTime.Now.Ticks); return(WxHttp.Get <JsapiTicket>(url)); }
/// <summary> /// 获取用户基本信息 /// </summary> /// <param name="accessToken"></param> /// <param name="openId"></param> /// <param name="lang"></param> /// <returns></returns> public static UserInfo GetUserInfo(string accessToken, string openId, string lang = "zh_CN") { var url = WxUrl.GetUserInfo.ToFormat(accessToken, openId, lang); return(WxHttp.Get <UserInfo>(url)); }
/// <summary> /// 查询所有分组 /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public static GroupList GetGroup(string accessToken) { var url = WxUrl.GetGroups.ToFormat(accessToken); return(WxHttp.Get <GroupList>(url)); }
/// <summary> /// 通过OAuthAccessToken获取用户信息 /// </summary> /// <returns></returns> public static OAuthUserInfo GetOAuthUserInfo(string oAuthAccessToken, string openId, string lang = "zh_CN") { var url = WxUrl.SnsApiUserInfo.ToFormat(oAuthAccessToken, openId, lang); return(WxHttp.Get <OAuthUserInfo>(url)); }
/// <summary> /// 刷新access_token(如果需要) /// </summary> /// <param name="appId"></param> /// <param name="refreshToken">填写通过access_token获取到的refresh_token参数</param> /// <param name="grantType"></param> /// <returns></returns> public static OAuthAccessToken RefreshToken(string appId, string refreshToken, string grantType = "refresh_token") { var url = WxUrl.RefreshCodeAccessToken.ToFormat(appId, grantType, refreshToken); return(WxHttp.Get <OAuthAccessToken>(url)); }
/// <summary> /// 获取AccessToken /// </summary> /// <param name="appId"></param> /// <param name="secret"></param> /// <param name="code">code作为换取access_token的票据,每次用户授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。</param> /// <param name="grantType"></param> /// <returns></returns> public static OAuthAccessToken GetAccessToken(string appId, string secret, string code, string grantType = "authorization_code") { var url = WxUrl.GetCodeAccessToken.ToFormat(appId, secret, code, grantType); return(WxHttp.Get <OAuthAccessToken>(url)); }