With the new version of ManiaHome just released, we also updated the ManiaHome PHP Library. It's now easier to use and hopefully many community services will interact with ManiaHome.Latest ManiaHome SDK version
1.01, April 20th
The ManiaHome PHP Library allows you to post notifications to ManiaHome, more precisely you can:
Post a notification to everyone who bookmarked your Manialink
eg. "Keep your fans posted about new updates on your Manialink or your Website"
Post a public notification to a Player
eg. "Tell to someone's buddies that he just uploaded a track on ManiaSpace, or beat a World record, etc."
Post a private notification to a Player
eg. "Information that is no need to be public, for example 'Your ad has been validated on ManiaPub'."
In this how-to, we'll see how to integrate ManiaHome notification posting into your system. It's very easy and does not require any particular skill (except basic PHP skills that you should already have if you are reading this...).
1 - Requirements
In order to use the ManiaHome library you need a few things.
* PHP 5.2
* CURL extension http://php.net/manual/en/book.curl.php
* JSON extension http://php.net/manual/en/book.json.php
* Your Web Server must be configured to that you can make HTTPS requests to external servers (namely api.maniastudio.com)
2 - Create an API user
In order to communicate with our API, you will need an API user. To do that:
* Head to http://developers.trackmania.com
* Login with your TrackMania account
* Go to API > Create new API user
3 - Register your Manialink on ManiaHome
You need to register your Manialink so you can post notifications, and you need to allow the API user you just created to post notifications for that Manialink. To do that:
Launch TrackMania
Go to maniahome
Go to Options > Manager > Your Manialink > Add a Manialink
Note: you need to be the owner of the Manialink!
On the "API username" page, select in the list the API user you created at step 2.
4 - Download the ManiaHome PHP Library
Download the latest version of the ManiaHome SDK at:
http://code.google.com/p/manialib/downloads/list
5 - Basic usage
Put the file "maniahome.php" in your project, so you can include it where you want to use it.
The code to use could not be simplier, so let's take a look at a quick example:
Code: Select all
require_once '/path/to/maniahome.php';
$maniahome = new ManiaHome('your_manialink', 'api_username', 'api_password');
// To everyone who bookmarked your manialink:
$maniahome->sendNotificationFromManialink('Hello world');
// Public notification to a player:
$maniahome->sendPublicNotificationToPlayer('player_login', 'rocks!');
// Private notification to a player:
$maniahome->sendPrivateNotificationToPlayer('player_login', 'This is a private message for you');
Error handling
All the methods to send notifications return true on success, false on failure. You can check errors like that:
Code: Select all
if( ! $maniahome->sendNotificationFromManialink('Lorem ipsuml dolor sit amet') )
{
echo 'ERROR: ' . $maniahome->lastResponse;
}
The methods to send notifications have several optional parameters. Look at the code for more information. Let's however do a little example (note that it does not work on private notifications!) :
Code: Select all
$maniahome->sendPublicNotificationToPlayer('player_login', 'rocks!', 'Icons128x128_1', 'Solo');
http://fish.stabb.de/styles/
Hope it helps!
Appendix - SDK changelog
1.01 - April 20th 2011
- Fixed bug when posting notifications with Icons style+substyle
1.0 - April 19th 2011
+ Initial release