NOTE: Get an APIKey.
<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <script type="text/javascript"> jQuery.ajax('https://www.thegamecrafter.com/api/session', { type : 'POST', data : { username : "joe", password : "abc123", api_key_id : "" // get your own }, dataType : "json", success : function(data) { var session = data.result; alert('Session ID: ' + session.id); }, error : function(jqxhr, text_status, error_thrown) { var result = jQuery.parseJSON(jqxhr.responseText); if (result.error) { alert(result.error.message); } else { alert('Error communicating with server.'); } } }); </script>
jQuery.ajax('https://www.thegamecrafter.com/api/user/' + session.user_id, { type : 'GET', data : { session_id : session.id }, dataType : "json", success : function(data) { var user = data.result; } });
jQuery.ajax('https://www.thegamecrafter.com/api/file', { type : 'POST', enctype : 'multipart/form-data', data : { file : '/path/to/image.jpg', name : 'image.jpg', folder_id : user.root_folder_id, session_id : session.id }, dataType : "json", success : function(data) { var file = data.result; } });
<script type="text/javascript"> jQuery.ajax('https://www.thegamecrafter.com/api/game', { type : 'GET', data : { q : "Steampunk", session_id : "XXX", // optional }, dataType : "json", success : function(data) { // output the list of games to the page jQuery.each(data.result.items, function(game) { $('body').append('<div id="'+ game.id +'">' + game.name + '</div>'); }); } }); </script>
Session ID is optional for this.