我正在使用 azure 市场上提供的 api,但是当我尝试在 Gmod 13 的 E2 芯片中使用它时,我收到以下错误...
The authorization type you provided is not supported. Only Basic and OAuth are supported
现在,我已经检查了一种身份验证方法,但我找不到。
这是我的代码...它是从其他人的代码中重新制作的,该代码使用了损坏的 dictionary.com 翻译器。
@name Language Translator - By Moglizorz - Patched by Scorn (test 6)
@persist Lang:string
#Test 1: Attempted to adjust the old translation api to detect single word entries.
#Test 2: Attempted to add support for both 1 word and multi-word entries,
#Test 3: After the failures of test 1 and 2, I have attempted to move to the Google translate.
#Test 4: Google is unresponsive, I have found the bing translator api and am attempting to use it.
#Test 5: Correction on last test: Its the Microsoft translation api. Also, I am getting an error over and over regarding failed authorization. Attempting to change from https to http.
#Test 6: I have reverted Test 5 due to identical failure, and have removed some unnecessary code.
runOnChat(1)
runOnHTTP(1)
if(first()){Lang="en"}elseif(duped()){reset()}
if((chatClk(owner()))&(lastSaid():sub(1,6)=="!lang ")){
hideChat(1)
print("[Hidden] Set language to: "+lastSaid():sub(6))
Lang=lastSaid():sub(7,lastSaid():length())
}elseif((lastSaid():sub(1,1)=="~")&(chatClk(owner()))){
hideChat(1)
print("[Hidden] Translating: "+lastSaid():sub(2))
httpRequest("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text="+httpUrlEncode(lastSaid():sub(2,lastSaid():length()))+"&From=en&to="+Lang )
}
if((httpClk())&(httpRequestUrl():find("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text=")>0)) {
S=httpData()
S=S:replace("&","&"):replace(""","\"")
S=httpUrlDecode(S)
concmd("say\""+S+"\"")
}
#To be added: Two way support. So that the person I am talking to will have their text translated to me locally.
您可能会注意到与 PHP 和 LUA 的一些相似之处……这就是您的 E2。
如果你想测试它,你需要GMOD13,并且必须事先在控制台中使用wire_expression2_concmd 1。
您还可以在Expression2找到 E2 语言的所有文档(存档链接)