1

我正在使用 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 语言的所有文档(存档链接

4

1 回答 1

2

您看到的输出来自以下语句:

httpRequest("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text="+httpUrlEncode(lastSaid():sub(2,lastSaid():length()))+"&From=en&to="+Lang )

根据微软翻译架构

该服务支持固定查询。某些查询可能包含必需的输入参数。

强调我的

现在,创建固定查询的方法也包含在本主题的帮助文档中。正如您在文档的第 4 步中所注意到的,您会看到它们具有:

private const string USER_ID = "yourLiveId";
private const string SECURE_ACCOUNT_ID = "yourMarketplaceAccountKey";  // not your Live password
private const string ROOT_SERVICE_URL = "https://api.datamarket.azure.com/Data.ashx/Alteryx/CensusDemographicData";

稍后在同一个代码块中

public CensusDemographicData()
{
    serviceUri = new Uri(ROOT_SERVICE_URL);
    context = new CensusDemographicDataContainer(serviceUri);
    context.IgnoreMissingProperties = true;
    context.Credentials = new NetworkCredential(USER_ID,
                                                SECURE_ACCOUNT_ID);

您缺少Credentials查询中的参数;这根本不固定。

于 2013-10-14T11:42:49.490 回答