[Sample] Creating a PNG signature banner with rankings

Maniaplanet public API, ManiaConnect system and the open source PHP SDK.

Moderator: NADEO

Post Reply
User avatar
Electron
Posts: 797
Joined: 15 Jun 2010, 18:02
Contact:

[Sample] Creating a PNG signature banner with rankings

Post by Electron »

Someone ask me how to create a PNG signature banner that indicates the player rankings.
I doesn't stored the PM's of my step-by-step guide, but I can publish the final PHP project files here.

After installing you get a signature banner like this:
Image

It's a very basic sample. To change the background image, the fonts and the format you have to edit the PHP source code.

The ZIP archive includes already the latest Maniaplanet Web Services library. So you doesn't care about file paths.
Unzip the archive inside \xampp\htdocs or \My Websites if you want to test the project locally with XAMPP or Microsoft Expression Web. Or put the files directly on your website.

To configure the signature banner you only need the following two steps:
1. Add your Maniaplanet Web Services username and password to the file "/banner/signature.php".
2. Give write permissions (0666) to the cache file "cache.dat".

You can create the required API credentials on your player page.
This is needed to access the Nadeo stats server. More information can be found here.
You only need to create an API user. For example use "banner" as identifier to get "<your_login>|banner" as Maniaplanet Web Services username. You do not need to create a ManiaConnect application for this project. This project only accesses the Players, Zones and Rankings classes.

You can test your newly created API username and password by accessing this file with you web browser. If you can see gouxim's nickname and zone than everything is good and you can add the credentials to the file signature.php.

To get the signature banner PNG image, call the signature.php with the two parameters login= and title=.
e.g. http://<yourdomain.tld>/banner/signature.php?login=hylis&title=SMStorm

A icon indicates the selected environment/title and the used rankings.
If your nickname misses some special characters, upload a font that includes more Unicode characters.

As a PHP beginner I'd be much obliged about suggestions for improvement.

Credits: TMFColorParser by oorf|fuckfish, mapCountry function (borrowed from XAseco) by Xymph, Flags by M. James (famfamfam.com), Icons (I reduced the size) and MPWS library by Nadeo

Download: signature.zip (743 KB)
Image
TM²: TrackMania Telemetry Monitor version 1.2.4
User avatar
Rots
Translator
Translator
Posts: 1101
Joined: 01 Sep 2010, 14:39
Location: España, Barcelona

Re: [Sample] Creating a PNG signature banner with rankings

Post by Rots »

Gonna give it a try ;)

For the moment it is nice since you can edit all the signature parameters and load it to your own server

Would be nice to have the posibility to choose background...

if storm // case SMStorm
$banner = 'storm.png'
if canyon
$banner = 'canyon' ...

easy to implement


Last bumped by Electron on 21 Jul 2014, 21:21.
Image
Image
Image
TrackMania Original brought me here... Here I am since 2006
Post Reply

Return to “Maniaplanet Web Services”

Who is online

Users browsing this forum: No registered users and 1 guest