haxe library for GameJolt cloud api version 1.2
With an html target, username and auth token are passed as arguments and can be retrieved with something like the following.
import js.html.URLSearchParams;
var url:String = document.URL;
if (-1 != url.indexOf( "index.html?" ))
{
var usp = new URLSearchParams( url.split( "index.html?" )[1] );
gjapi_username = usp.get( "gjapi_username" );
gjapi_token = usp.get( "gjapi_token" );
}
To call an api function, first set the appropriate static variables in gjCloud.GJTransaction
import gjCloud.*;
GJTransaction.appID = "000000"; // get this from your GameJolt dashboard
GJTransaction.appPrivateKey = ""; // get this from your GameJolt dashboard
GJTransaction.userName = gjapi_username; // retrieved earlier
GJTransaction.userAuth = gjapi_token; // retrieved earlier
And then do something like one of the following:
var tr:GJTransaction;
// call right away
tr = GJUsers.auth().get( gj_callbackdata, gj_callbackerror );
// create a transaction and call it later, perhaps several times
tr = GJTime.fetch();
tr.get( gj_callbackdata, gj_callbackerror );
// batch together several api calls
tr = GJBatch.batch();
tr.add( GJSessions.check() );
tr.add( GJSessions.open() );
tr.add( GJSessions.check() );
tr.add( GJSessions.ping() );
tr.add( GJSessions.check() );
tr.add( GJSessions.close() );
tr.add( GJSessions.check() );
tr.get( gj_callbackdata, gj_callbackerror ); // you can batch up to 50 api calls at once
function gj_callbackdata():Void {}
function gj_callbackerror():Void {}