Validate invite token API

From WarLight Wiki
Jump to: navigation, search

If you're creating a system that invites players to WarLight games via the Create game API, you may wish to validate whether or not an invite token or e-mail address is valid before you attempt to invite them to a game.

Of course, if you invite a player to a game with their token, the Create game API will inform you that it's invalid. But you may wish to determine whether or not it's valid before attempting to create a game, such as when a new player signs up on your site.

You can do this by calling the following API: https://www.warlight.net/API/ValidateInviteToken?Token=12345678

To call this programmatically, you can POST your e-mail address and API token to this page in the format Email=your@email.com&APIToken=yourapitoken You can get your API token from the Get API Token API.

This will return the following fields about the player whose token you provided:

  • tokenIsValid: This simply tells you that the token does belong to a WarLight player.
  • name: The player's WarLight nickname.
  • isMember: True if the player has purchased a WarLight membership.
  • level: Their current level.
  • color: The player's preferred WarLight color.
  • tagLine: The tagline the player has set up to display on their profile page.
  • clotpass: See CLOT Authentication
  • createPlayerLimit: The maximum game size that they can create.
  • lowestUsableLuckModifier: The lowest setting they can specify for the luck modifier when creating games.
  • levelForMapUsage: The level the system considers them when determining what maps they can use. If their level is 5, but their levelForMapUsage is 10, they can use maps that unlock at 6-10, even though their level isn't techincally high enough.
  • featuresUnlocked: What features they've unlocked, either from leveling up or purchasing a membership.
  • onVacationUntil: Expiration date of current vacation.

[edit] Template IDs

Optionally, you can also provide a list of Template IDs to this API. The API will check if the player has access to be a part of games created by the Create game API using this template.

This is helpful if you plan to invite them to a game via the API and you don't want to manually check their featuresUnlocked parameter against the features you know that your template uses.

To use this, provide a parameter named TemplateIDs (either via the query string or POST param) which contains a comma-delimited list of template IDs. You may pass up to 20 template IDs per call.

An example request would look like https://www.warlight.net/API/ValidateInviteToken?Token=12345678&TemplateIDs=342040,342041,342042,342043

The API will return results for each template ID provided in the returned JSON. Each template will return a "result" node that contains the string "CanUseTemplate", "CannotUseTemplate", or another string if an error occurred. If "CannotUseTemplate" is returned, there will be an additional node named "reasonCode" that explains why the player was unable to use the template.

An example return looks like this:

 "template342040": {
   "result": "CanUseTemplate"
 },
 "template342041": {
   "result": "CannotUseTemplate",
   "reasonCode": "MapLocked"
 },
 "template342042": {
   "result": "CannotUseTemplate",
   "reasonCode": "AttackOnlyTransferOnlyLocked"
 },
 "template342043": {
   "result": "error: template not found"
 }


[edit] See Also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox