Kongregate General Services APIThe Kongregate Services API allows access to some common functions that you may find useful while developing your game. It can be used to get information about the player, including username, guest status, authentication token, etc. API FunctionsConnecting
The connect():void
kongregate.services.connect(); Checking if the user is a guest
The isGuest():Boolean
var isGuest:Boolean = kongregate.services.isGuest(); Getting the player's Kongregate username
You can use the getUsername():String
var username:String = kongregate.services.getUsername(); Getting the player's Kongregate user id
You can use the getUserId():String
var user_id:Number = kongregate.services.getUserId(); Getting the player's game authentication token
If you are using the Authentication API you can use the getGameAuthToken():String
var token:String = kongregate.services.getGameAuthToken(); Showing the sign-in box
If the player is a guest, and you want to display the sign-in/registration UI to them (for example, if you want to upsell them to buy an item or you want to use the authentication API), you can use the showSignInBox():void
if(kongregate.services.isGuest()){ kongregate.services.showSignInBox(); } Showing the registration boxThis call works the same way as showSigninBox, but it focuses the registration form rather than the sign-in form. showRegistrationBox():void
if(kongregate.services.isGuest()){ kongregate.services.showRegistrationBox(); } Showing the shout boxIf a player is logged-in and you want to allow them to post a shout on their profile page, you may bring up the shout box, optionally populated with some initial content. showShoutBox(initialMessage:String):void
if(!kongregate.services.isGuest()){ kongregate.services.showShoutBox("I accidentally the whole thing!"); } Resizing the enclosing iframeIf you need to resize your game's enclosing container, you may do so with resizeGame call. The enclosing iframe will resize around your game. Games may not be resized smaller than their initial dimensions. (Please note: at the moment this API requires special permission to use - please email us at developer_support@kongregate.com to request access.) resizeGame(x:Number, y:Number):void
kongregate.services.resizeGame(900, 650); You can read the section on handling guests for more information on how to tell when a user completes registration or signing in. |