private static string getFromBaidu() { string resultJson = HttpWebRequestHelper.GetBaiduAcesessToken( BaiduAipHelper.BaiduTokenUrl, ConfigurationHelper.GetConfig(ConfigItemName.baiduApiKey.ToString()), ConfigurationHelper.GetConfig(ConfigItemName.baiduApiSecretKey.ToString()) ); string replaceJson = StringHelper.jsonCamelCaseToDBnameing(resultJson); mToken = JsonHelper.JsonToObject(replaceJson, typeof(BDAccessToken)) as BDAccessToken; mToken.getDate = DateTimeHelper.getCurrentDateTime(); if (mToken.error != null) { return(null); } else { writeToxml(); return(mToken.accessToken); } }
private static string getFromXml() { try { if (MyHelper.FileHelper.FolderExistsCreater(tokenFilePath)) { if (!FileHelper.Exists(tokenXmlFilePath)) { FileHelper.CreateFile(tokenXmlFilePath); return(null); } string tokenstr = FileHelper.Reader(tokenXmlFilePath); if (!string.IsNullOrEmpty(tokenstr)) { mToken = XmlHelper.Deserialize(typeof(BDAccessToken), tokenstr) as BDAccessToken; if (mToken != null) { return(mToken.accessToken); } else { return(null); } } else { return(null); } } else { return(null); } } catch (Exception) { return(null); } }