HTTP请求将获取API获取数据。 Gamemaker Studio 1.4.9
我试图弄清楚如何从GameMaker Studio 1.4.9中的字典API获取信息,
因为我无法弄清楚如何绕过API的服务器块。我所有的返回显示都是空白的结果。
步骤事件:
if(keyboard_check_pressed(vk_space)){
http_get("https://api.dictionaryapi.dev/api/v2/entries/en/test");
}
HTTP事件:
var requestResult = ds_map_find_value(async_load, "result");
var resultMap = json_decode(requestResult);
if(resultMap == -1)
{
show_message("Invalid result");
exit;
}
if(ds_map_exists(resultMap,"word")){
var name= ds_map_find_value(resultMap, "word");
show_message("The word name is "+name);
}
也许我的格式是错误的?应该在show_message函数中说一个单词测试,但同样,我返回的只是一个空白的结果。
任何帮助将不胜感激,谢谢!
I'm trying to figure out how to get information from a dictionary API in Gamemaker Studio 1.4.9
I'm lost since I can't figure out how to get around the API's server block. All my return shows is a blank result.
Step Event:
if(keyboard_check_pressed(vk_space)){
http_get("https://api.dictionaryapi.dev/api/v2/entries/en/test");
}
HTTP Event:
var requestResult = ds_map_find_value(async_load, "result");
var resultMap = json_decode(requestResult);
if(resultMap == -1)
{
show_message("Invalid result");
exit;
}
if(ds_map_exists(resultMap,"word")){
var name= ds_map_find_value(resultMap, "word");
show_message("The word name is "+name);
}
Maybe my formatting is wrong? It's supposed to say the word test in the show_message function, but again, all I get returned is a blank result.
Any help would be appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过调试器看到数据来自服务器。但是您的代码无法正确尝试检索单词。
https://i.sstatic.net/pzrsb.jpg
此代码获得此词
You can see through the debugger that the data is coming from the server. But your code does not correctly try to retrieve the Word.
https://i.sstatic.net/PzRSb.jpg
This code gets this word