Someone gifted MetalSlayer69 supporter status!
We need you on the team, too.
Support Newgrounds and get tons of perks for just $2.99!
Create a Free Account and then..
Become a Supporter!At 3/4/23 10:57 AM, bodziozet wrote:At 3/4/23 10:28 AM, bodziozet wrote:Furthermore if you want to make an api call for example using native Game Maker Studio 2 functions other than the newgrounds.api extension for example http_post_string you do not post only json string but to the json string you append at the begining something like "request=".At 2/24/23 09:00 PM, bodziozet wrote: Hi. I wanted to get a feel on how newgrounds.io api works but in reality i cannot even made the simplest of calls myself . Im using postman. Im using this adress https://www.newgrounds.io/gateway_v3.php . Im selecting method POST and then in the body section im clicking raw and then selecting JSON. then I already tried to send this 3 JSON objects:Ok. So at least i think i know what is happening in this situation. All these API calls do not work because newgrounds.api expect you to send something more than a JSON string. It wants a key : value pair where key is either request or input and the value is a JSON string. It's like you would submit a form to the gateway it would send a key : value pair where the key is the name of the textarea in which you wrote the JSON String. So if somebody wants to test the api with postman you have to send the JSON not as raw JSON butas form-data and then you add new key value pair where key is request and value is your JSON string.
1.
{
"app_id": "test",
"debug": true,
"execute": {
"component": "Gateway.getDatetime",
"parameters": {},
"echo": "Hello World!"
}
}
2.
3.
In all 3 cases im getting the same response :
{
"success": false,
"error": {
"message": "Missing required request",
"code": 100
},
"api_version": "3.0.0",
"help_url": "http://www.newgrounds.com/wiki/creator-resources/newgrounds-apis/newgrounds-io"
}
What em i doing wrong? Please help.
Im sory for posting another reply to myself but i cannot edit the reply before. So I want to use a native Game maker Studio 2 function like http_post_string() because i do not understand how the newgorunds.api extension function for Game maker Studio 2 called ng_getScores supposed to work. When im looking at the source code the implementation looks like that:
function ng_getScores(board_app_id, board_id, board_limit, board_period, board_skip, board_social, board_tag, user_id_or_name) {
if (!ngio.user) return "";
for (var i = 0; i < scoreboards.length; i++) {
scoreboard = scoreboards[i];
if (board_id == scoreboard.id || board_id == scoreboard.name) {
thescoreboard = ngio.callComponent('ScoreBoard.getScores', { app_id: board_app_id, id: scoreboard.id, limit: board_limit, period: board_period, skip: board_skip, social: board_social, tag: board_tag, user: user_id_or_name });
return thescoreboard;
}
}
}
So the function returns thescoreboard so it probably should be used like that var thescoreboard = ng_getScores(parameters). But this function under the hood uses ngio.callComponent() which looks like an asynchronous call. So this not supposed to work. When im using native function like http_post_string then when the function returns then an Asynchronous Http event will be triggerd in which i can handle the response.
At 3/4/23 10:57 AM, bodziozet wrote:At 3/4/23 10:28 AM, bodziozet wrote:Furthermore if you want to make an api call for example using native Game Maker Studio 2 functions other than the newgrounds.api extension for example http_post_string you do not post only json string but to the json string you append at the begining something like "request=".At 2/24/23 09:00 PM, bodziozet wrote: Hi. I wanted to get a feel on how newgrounds.io api works but in reality i cannot even made the simplest of calls myself . Im using postman. Im using this adress https://www.newgrounds.io/gateway_v3.php . Im selecting method POST and then in the body section im clicking raw and then selecting JSON. then I already tried to send this 3 JSON objects:Ok. So at least i think i know what is happening in this situation. All these API calls do not work because newgrounds.api expect you to send something more than a JSON string. It wants a key : value pair where key is either request or input and the value is a JSON string. It's like you would submit a form to the gateway it would send a key : value pair where the key is the name of the textarea in which you wrote the JSON String. So if somebody wants to test the api with postman you have to send the JSON not as raw JSON butas form-data and then you add new key value pair where key is request and value is your JSON string.
1.
{
"app_id": "test",
"debug": true,
"execute": {
"component": "Gateway.getDatetime",
"parameters": {},
"echo": "Hello World!"
}
}
2.
3.
In all 3 cases im getting the same response :
{
"success": false,
"error": {
"message": "Missing required request",
"code": 100
},
"api_version": "3.0.0",
"help_url": "http://www.newgrounds.com/wiki/creator-resources/newgrounds-apis/newgrounds-io"
}
What em i doing wrong? Please help.
Im sory for posting another reply to myself but i cannot edit the reply before. So I want to use a native Game maker Studio 2 function like http_post_string() because i do not understand how the newgorunds.api extension function for Game maker Studio 2 called ng_getScores supposed to work. When im looking at the source code the implementation looks like that:
function ng_getScores(board_app_id, board_id, board_limit, board_period, board_skip, board_social, board_tag, user_id_or_name) { if (!ngio.user) return ""; for (var i = 0; i < scoreboards.length; i++) { scoreboard = scoreboards[i]; if (board_id == scoreboard.id || board_id == scoreboard.name) { thescoreboard = ngio.callComponent('ScoreBoard.getScores', { app_id: board_app_id, id: scoreboard.id, limit: board_limit, period: board_period, skip: board_skip, social: board_social, tag: board_tag, user: user_id_or_name }); return thescoreboard; } } }
So the function returns thescoreboard so it probably should be used like that var thescoreboard = ng_getScores(parameters). But this function under the hood uses ngio.callComponent() which looks like an asynchronous call. So this not supposed to work. When im using native function like http_post_string then when the function returns then an Asynchronous Http event will be triggerd in which i can handle the response.