我正在使用天蓝色市场上的api,但是当我尝试在Emod 13的E2芯片中使用它时,我收到以下错误...
The authorization type you provided is not supported. Only Basic and OAuth are supported
现在,我已经检查过验证方法,但我找不到。
这是我的代码......它是使用词典翻译器破坏的某些代码重新制作的。
@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。
找到E2语言的所有文档答案 0 :(得分:1)
您看到的输出来自以下声明:
httpRequest("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text="+httpUrlEncode(lastSaid():sub(2,lastSaid():length()))+"&From=en&to="+Lang )
此服务支持固定查询。某些查询可能包含必填项 输入参数。
强调我的
现在,this topic中的帮助文档也涵盖了创建固定查询的方法。正如您在文档Step 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
个参数;这根本不固定。