| | |
| | | /// <returns></returns> |
| | | public static string GetAccessToken() |
| | | { |
| | | string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials"); |
| | | string returnStr = BDWebRequest(url, "", "POST"); |
| | | //string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials"); |
| | | //string returnStr = BDWebRequest(url, "", "POST"); |
| | | |
| | | NLog.LogManager.GetCurrentClassLogger().Trace("ç¾åº¦äººè¸è¯å«è¿åï¼" + returnStr); |
| | | BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr); |
| | | token.getdate = DateTime.Now.ToString(); |
| | | //NLog.LogManager.GetCurrentClassLogger().Trace("ç¾åº¦äººè¸è¯å«è¿åï¼" + returnStr); |
| | | //BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr); |
| | | //token.getdate = DateTime.Now.ToString(); |
| | | |
| | | return token.access_token; |
| | | //return token.access_token; |
| | | |
| | | |
| | | var str = "24.83aee44079e5a27530bc72d5ec7049a3.2592000.1746152354.282335-118294290"; |
| | | return str; |
| | | } |
| | | |
| | | public static string BDWebRequest(string url, string data, string method) |
| | |
| | | /// </summary> |
| | | /// <param name="path">æä»¶è·¯å¾</param> |
| | | /// <returns>base64ç¼ç ä¿¡æ¯ï¼ä¸å¸¦æä»¶å¤´</returns> |
| | | public static string GetFileContentAsBase64(string path) |
| | | //public static string GetFileContentAsBase64(string path) |
| | | //{ |
| | | // using (FileStream filestream = new FileStream(path, FileMode.Open)) |
| | | // { |
| | | // byte[] arr = new byte[filestream.Length]; |
| | | // filestream.Read(arr, 0, (int)filestream.Length); |
| | | // string base64 = Convert.ToBase64String(arr); |
| | | // return base64; |
| | | // } |
| | | //} |
| | | public static string GetFileContentAsBase64(string filePath) |
| | | { |
| | | using (FileStream filestream = new FileStream(path, FileMode.Open)) |
| | | // åªä¿çæä»¶åï¼é¿å
è·¯å¾é误 |
| | | string fileName = Path.GetFileName(filePath); |
| | | |
| | | // è·åæä»¶ç宿´è·¯å¾ |
| | | string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "image", fileName); |
| | | |
| | | if (!File.Exists(fullPath)) |
| | | { |
| | | throw new FileNotFoundException("æä»¶ä¸åå¨ï¼" + fullPath); |
| | | } |
| | | |
| | | using (FileStream filestream = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) |
| | | { |
| | | byte[] arr = new byte[filestream.Length]; |
| | | filestream.Read(arr, 0, (int)filestream.Length); |
| | | string base64 = Convert.ToBase64String(arr); |
| | | return base64; |
| | | filestream.Read(arr, 0, arr.Length); |
| | | return Convert.ToBase64String(arr); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// äººè¸æ³¨å |
| | |
| | | /// <summary> |
| | | /// ç¨æ·ç»idï¼æ è¯ä¸ç»ç¨æ·ï¼ç±æ°åã忝ãä¸åçº¿ç»æï¼ï¼é¿åº¦éå¶48B |
| | | /// </summary> |
| | | public int group_id { get; set; } |
| | | public string group_id { get; set; } |
| | | /// <summary> |
| | | /// ç¨æ·idï¼ç±æ°åã忝ãä¸åçº¿ç»æï¼ï¼å¯¹åºç³»ç»è´¦å· |
| | | /// </summary> |