public static void TranslationDetection(string englishText)
        {
            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("clientID", "client secret");//NepaliWikipediaTranslator
            AdmAuthentication admAuth = new AdmAuthentication("NepaliWikipediaTranslator", "vUo0WWvT6CQvaQO1CuFCvU/gkstlhy2TXYxqOj4aOPY=");

            try
            {
                admToken = admAuth.GetAccessToken();
                // Create a header with the access_token property of the returned token
                headerValue = "Bearer " + admToken.access_token;
                DetectMethod(headerValue, englishText);
            }
            catch (WebException e)
            {
                ProcessWebException(e);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            AdmAccessToken admToken;
            string         headerValue;

            AdmAuthentication admAuth = new AdmAuthentication();

            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 e)
            {
                // ProcessWebException(e);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
        }
        public static AdmAccessToken GetAccessToken()
        {
            //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/
            AdmAuthentication admAuth = new AdmAuthentication("9a086c79-36a3-487a-9e87-8332ed05090d", "Tkpy6Rd682QCPaEvxKcDFe42ssMpMbL435yFJJkEjao=");

            //Gets acess token
            AdmAccessToken admToken = admAuth.GetAccessToken();

            return(admToken);
        }
        public static AdmAccessToken GetAccessToken()
        {
            //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/
            AdmAuthentication admAuth = new AdmAuthentication("9a086c79-36a3-487a-9e87-8332ed05090d", "Tkpy6Rd682QCPaEvxKcDFe42ssMpMbL435yFJJkEjao=");

            //Gets acess token
            AdmAccessToken admToken = admAuth.GetAccessToken();

            return admToken;
        }