public override string TranslateToChinese(string englishSentence) { AdmAccessToken admToken; string headerValue; //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/ //Refer obtaining AccessToken (http://msdn.microsoft.com/en-us/library/hh454950.aspx) AdmAuthentication admAuth = new AdmAuthentication("LearnEnglishBySubtitle", "hKBp2IPbGOnpo/lfFlPRvYPSRUb2pRSYMYfmSOauFFc="); try { admToken = admAuth.GetAccessToken(); // Create a header with the access_token property of the returned token headerValue = "Bearer " + admToken.access_token; return(TranslateMethod(headerValue, englishSentence)); } catch (WebException ex) { ProcessWebException(ex); return(ex.Message); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(ex.Message); } }
private void button3_Click(object sender, EventArgs e) { AdmAccessToken admToken; string headerValue; //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/ //Refer obtaining AccessToken (http://msdn.microsoft.com/en-us/library/hh454950.aspx) AdmAuthentication admAuth = new AdmAuthentication("LearnEnglishBySubtitle", "hKBp2IPbGOnpo/lfFlPRvYPSRUb2pRSYMYfmSOauFFc="); try { admToken = admAuth.GetAccessToken(); // Create a header with the access_token property of the returned token headerValue = "Bearer " + admToken.access_token; TranslateMethod(headerValue); } catch (WebException ex) { ProcessWebException(ex); Debug.WriteLine("Press any key to continue..."); } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine("Press any key to continue..."); } }
public override string TranslateToChinese(string englishSentence) { AdmAccessToken admToken; string headerValue; //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/ //Refer obtaining AccessToken (http://msdn.microsoft.com/en-us/library/hh454950.aspx) AdmAuthentication admAuth = new AdmAuthentication("LearnEnglishBySubtitle", "hKBp2IPbGOnpo/lfFlPRvYPSRUb2pRSYMYfmSOauFFc="); try { admToken = admAuth.GetAccessToken(); // Create a header with the access_token property of the returned token headerValue = "Bearer " + admToken.access_token; return TranslateMethod(headerValue,englishSentence); } catch (WebException ex) { ProcessWebException(ex); return ex.Message; } catch (Exception ex) { Debug.WriteLine(ex.Message); return ex.Message; } }