Habitica Wiki
Habitica Wiki
Advertisement
Habitica Wiki

This software stopped working after 30 July 2016 when Habitica's deprecated API v2 was removed.

Information about the API change can be found at Application Programming Interface.


Screenshot

Php-widget

Description

A widget displaying a player's user name, current appearance and select stats (level, class, health, XP and mana) that can be placed on the player's own website.

It can run as a PHP include off your own server or as an iframe. There is also a WordPress-specific version created by gersande available here.

Usage

Running on your own server
To run this on your own server you will need the following files:

  • get-character.php
  • habitrpg.css (inside inc folder)
  • habitrpg-api.php (inside inc folder)
  • habitrpg and its contents in the img folder

After placing all the files where they belong, edit the habitrpg-api.php file to have your API key and User ID for the appropriate variables. Then chmod the file to have read and write permissions for user only (600) to keep those keys secure.

Wherever you want the widget to show up, use a php include and include get-character.php.

You also might need to edit the include or image paths if you don't have the files placed in the "inc" or "img" folder.

Running through an iframe
If you don't want to host all the files on your server you can accomplish this two ways.

Method 1
Place the habitrpg-api.php file in your inc folder.

Edit it to have your API key and User ID and then chmod the file to read and write permissions for user only (600) to keep those secure.

Then use the php include code from index.html between the method 1 tags. Place that at the very top of your webpage, even above the html tag. Then place the iframe code between the method one tags where you want it on your webpage. This will place an iframe that will display your info.

Method 2
This method is the least secure, but this method works if you want to display this character badge but cannot upload files to the web server (like Blogger or something similar).

In this method, copy the code from index.html between the method 2 tags and paste it where you want it.

Then replace PUT_USER_ID_HERE and PUT_API_KEY_HERE with your User ID and API key.

The reason this isn't secure is because the API key and User ID values would be visible in the HTML source, so someone could use this information to access your account through the API.

Advertisement