Result – Giavapps Game Jolt API

 

About Result Functions

 

Result functions are ment for processing result data returned from any HTTP request to the Game Jolt API.

 

Result Functions

 

Once you called gj_http_result function you can then process the retrieved result data with the following functions:

 

gj_result_success() Returns true if the current HTTP request succeed and so the success field is equal to "true" or false otherwise.

 

gj_result_message() Returns the value (a string) of the message field. The server sends a message field when the current HTTP request fails and so the success field is equal to "false".

 

gj_result_count() Returns the total number of results for the current HTTP request.

 

gj_result_field_count() Returns the total number of fields (or parameters) available for the current HTTP request.

 

gj_result_field_name(double field_id) Returns the name of the given field available for the current HTTP request..

double field_id: zero-based index of the field.

 

gj_result_field_value(double result_id, string field_name) Returns the value (a string) for the specific result and the given field available for the current HTTP request..

double result_id: zero-based index of the result.

string field_name: name of the field.

 

Code Examples

 

Processing Multiple Results

 

Create Event

 

gj_init("game_id","private_key");//Initializes Giavapps Game Jolt API
request_user_auth = gj_user_auth("username","user_token");//Authenticates the user
request_trophy_fetch_all = –1;//Request for fetching all trophies

 

Game End Event

 

gj_deinit();//Deinitializes Giavapps Game Jolt API

 

Async – HTTP Event

 

if(gj_http_status() != 0){exit;}//Checks if the status is complete

gj_http_result();//Retrieves result data for gj_result_* functions

if(gj_http_id() == request_user_auth)//Checks if the id is equal to the http request id
{

if(gj_result_success())
{
show_debug_message("THE USER’S CREDENTIALS ARE VALID!");
request_trophy_fetch_all = gj_trophy_fetch_all();//Fetches all trophies
}
else
{
show_debug_message("THE USER’S CREDENTIALS ARE INVALID!");
}

}
else if(gj_http_id() == request_trophy_fetch_all)//Checks if the id is equal to the http request id
{

if(gj_result_success())
{
show_debug_message("TROPHIES HAVE BEEN FETCHED!");

for(var r=0; r<gj_result_count(); r++)//Processes all results
{
show_debug_message("RESULT ID "+string(r)+":");

for(var f=0; f<gj_result_field_count(); f++)//Processes all fields
{
show_debug_message(gj_result_field_name(f)+"="+gj_result_field_value(r, gj_result_field_name(f)));
}

}

}
else
{
show_debug_message("TROPHIES HAVE NOT BEEN FETCHED!");
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.