static string GetToken() { string str = LeoHttpHelper.Get($"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={AppID}&secret={AppSercet}"); var obj = str.ToDynamic(); return(obj.access_token); }
public static MiniLoginResult Login(string code) { string url = $"https://api.weixin.qq.com/sns/jscode2session?appid={AppID}&secret={AppSercet}&js_code={code}&grant_type=authorization_code"; string result = LeoHttpHelper.Get(url); MiniLoginResult loginResult = JsonConvert.DeserializeObject <MiniLoginResult>(result); return(loginResult); }
public static string SendMsg(MiniProgramTemplate template) { if (string.IsNullOrEmpty(template.touser) || string.IsNullOrEmpty(template.form_id)) { return(""); } string url = $"https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={GetToken()}"; string result = LeoHttpHelper.Post(url, JsonConvert.SerializeObject(template)); return(result); }
public static Image CreateShareCode(string str, string page) { string token = GetToken(); var pam = new { scene = str, page = page, width = 430 }; string url = $"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={token}"; byte[] bytes = LeoHttpHelper.PostGetByte(url, pam.ObjectToString()); Stream stream = new MemoryStream(bytes); return(Image.FromStream(stream)); }