00:00
00:00
Newgrounds Background Image Theme

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!
Response to: Newgrounds.io Help & Support Posted March 4th, 2023 in Game Development

At 3/4/23 10:57 AM, bodziozet wrote:
At 3/4/23 10:28 AM, bodziozet wrote:
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:
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.
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.
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=".


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.

Response to: Newgrounds.io Help & Support Posted March 4th, 2023 in Game Development

At 3/4/23 10:28 AM, bodziozet wrote:
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:
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.
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.


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=".

Response to: Newgrounds.io Help & Support Posted March 4th, 2023 in Game Development

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:
1.
{


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.

Response to: Newgrounds.io Help & Support Posted March 2nd, 2023 in Game Development

Hi i have a question about newgounds.io functions inside Game Maker 2 Studio. How to use ng_getScores() function? Under the hood the function seems to be asynchronous so the var score = ng_getScores(app_id, board_id) does not work properly or maybe i'm missing something?

Response to: Newgrounds.io Help & Support Posted February 25th, 2023 in Game Development

At 2/25/23 09:40 AM, 3p0ch wrote:
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.
I suspect it's something to do with how the post is structured by Postman, but you probably don't need to use Postman in the first place. What engine / framework are you making your game in? There are probably already implementations at https://www.newgrounds.io/get-started/#step-4-learn-how-to-use-the-api-components for whatever you're using, and even if you're making something from scratch there should be easier ways of doing it than having to use something like Postman, so it probably wouldn't be worth worrying about details of how to make Postman do what you want if that's not ultimately what would make sense to use in a game.

Hi thanks for your reply. I'm making my game in GameMaker2 and i already have a library of functions imported but i don't like how i cannot find documentation on how are these functions working and what are they returning so i tried to get a feel on how the api works and i cannot even make the call using postman or even i tried do the same in some online site that works like postman and i could not get success response. Using Game maker 2 functions i was unable to do what i wanted to do. I dont even understand if ng_connect function really connects to the server or only instantiate an object with app id and encryption keys that other functions will use.

Response to: Newgrounds.io Help & Support Posted February 24th, 2023 in Game Development

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:

1.

{

    "app_id": "test",

    "debug": true,

    "execute": {

        "component": "Gateway.getDatetime",

        "parameters": {},

        "echo": "Hello World!"

    }

}

2.

{


     "app_id": 'test',


     "session_id": null,


     "call": {


          "component": "Gateway.getVersion"


     }


}

3.

{


     "app_id": "test",


     "session_id": null,


     "call": {


          "component": "Gateway.getVersion"


     }


}

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.