TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CADwiesel on November 18, 2022, 04:46:17 AM
-
Hi Guys,
today i'm hoping to get help of the spetialists here.
My challange is to get the result from the deepL translate API but i couldn't send a valid question string.
I tried these two code snippets
[code=cadlisp-7];; Get URL Text - Lee Mac
;; Retrieves all text data for the given URL
(defun LM:geturltext ( url / obj rtn )
(if (setq obj (vlax-create-object "winhttp.winhttprequest.5.1"))
(progn
(setq rtn
(vl-catch-all-apply
'(lambda nil
(vlax-invoke-method obj 'open "GET" url :vlax-false)
(vlax-invoke-method obj 'send)
(vlax-get-property obj 'responsebody)
)
)
)
(vlax-release-object obj)
(if (vl-catch-all-error-p rtn)
(prompt (vl-catch-all-error-message rtn))
(vl-list->string
(mapcar '(lambda ( x ) (lsh (lsh x 24) -24))
(vlax-safearray->list (vlax-variant-value rtn))
)
)
)
)
)
)
[code=cadlisp-7];; Get-Http - Irneb
(defun Get-Http (URL / util fn f txt)
(setq util (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object))))
(if (and (vla-IsURL util URL)
(not (vl-catch-all-error-p
(vl-catch-all-apply 'vla-GetRemoteFile (list util URL 'fn :vlax-true))
)
)
(setq f (open fn "r"))
)
(progn
(while (setq fn (read-line f)) (setq txt (cons (strcat fn "\n") txt)))
(close f)
(apply 'strcat (reverse txt))
)
)
)
The DeepL rules for API quests looks like that:
curl -X POST 'https://api-free.deepl.com/v2/translate' \
-H 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
-d 'text=Hello%2C%20world!' \
-d 'target_lang=DE'
I tried to generate a string like that to use it with these both functions above:
"https://api-free.deepl.com/v2/translate/&Authorization:%2C%20DeepL-Auth-Key%2C%20a63b08eb-xxxxxx-7cd59c2f66d9:fx&text=Hello%2C%20world!&target_lang=DE"
How needs the string to be to get a translated result?
Thanks for spending Time into this!
-
This site "https://api-free.deepl.com/v2...." need more tests.
He cannot display translate messages even in Firefox.exe or GoogleChrome.exe or InternetExplorer8Win.
\Is not your fault & VLISP. because "https://api-free.deepl.com/ " need more tests with many operating-systems (win8, linux , ubuntu. win10, knoppix, android, winxp, ) with "MsEdge, FireFox, opera.exe,AcWeb, Comaxton.exe,)
If he failed inside so many operating systems, then "he=//api-free.deepl.com/"
--is broken. is zerop.
:woow:
After these tests minim70% succesfully, than You can execute in VLIDE with VLISP with "api-free.deepl.com/v2"
:hahanot:
-
in case you want to translate some autocad texts then you might try this app https://www.theswamp.org/index.php?topic=47908.0