Exemple #1
0
        public override void OnCreateRequest(IHttpRequestCreationContext context)
        {
            var request = new XUnityWebRequest(
                string.Format(
                    HttpsServicePointTemplateUrl,
                    context.SourceLanguage,
                    context.DestinationLanguage,
                    WwwHelper.EscapeUrl(context.UntranslatedText),
                    _key));

            request.Headers[HttpRequestHeader.Accept]        = "*/*";
            request.Headers[HttpRequestHeader.AcceptCharset] = "UTF-8";

            context.Complete(request);
        }
Exemple #2
0
        public override void OnCreateRequest(IHttpRequestCreationContext context)
        {
            string salt = DateTime.UtcNow.Millisecond.ToString();
            var    md5  = CreateMD5(_appId + context.UntranslatedText + salt + _appSecret);

            var request = new XUnityWebRequest(
                string.Format(
                    HttpServicePointTemplateUrl,
                    WwwHelper.EscapeUrl(context.UntranslatedText),
                    FixLanguage(context.SourceLanguage),
                    FixLanguage(context.DestinationLanguage),
                    _appId,
                    salt,
                    md5));

            request.Headers[HttpRequestHeader.UserAgent]     = string.IsNullOrEmpty(AutoTranslatorSettings.UserAgent) ? UserAgents.Chrome_Win10_Latest : AutoTranslatorSettings.UserAgent;
            request.Headers[HttpRequestHeader.AcceptCharset] = "UTF-8";

            context.Complete(request);
        }