PHT - CHPP Api
Welcome to PHT official page. PHT is an API for Hattrick CHPP applications written in PHP. It will help you with new CHPP login procedure!
PHT is fully OOP and allows you to fetch all datas available on Hattrick very easily.
Download lastest version: PHT
You can find all previous versions of PHT and changelog on archive page
Minimum required : PHP5 and cURL
How it works:
-
try
-
{
-
$HT = new CHPPConnection('chppName', 'chppId', 'chppKey');
-
if($HT->connectUser('user-login', 'user-security-code'))
-
{
-
echo $HT->getClub()->getTeamname() . '(' . $HT->getClub()->getTeamId() . ')';
-
$HT->disconnect();
-
}
-
else
-
{
-
echo "Login error !";
-
}
-
}
-
catch(HTError $e)
-
{
-
// Hattrick is down ? See exception message, error code, request, …
-
}
-
?>
You have to provide a server path to save Hattrick cookies or you won’t access any page after login.
PHT contains 324 classes and 1946 functions. You can get any data available for CHPP applications, if I missed something, just tell me and I will add it to next version.
The PhpDoc is joined to zip file, you can find every method. As all code is commented, if you use an editor with auto complete support, you will find what you search very easily!
Others examples:
-
…
-
$team = $HT->getTeam();
-
if($team->isHtSupporter())
-
{
-
echo $team->getPressAnnouncementDate() . ' - ' . $team->getPressAnnouncementTitle() . '<br/>' . $team->getPressAnnouncementText();
-
}
-
…
-
$match = $HT->getSeniorMatchDetails($matchId);
-
echo $match->getScore();
-
echo $match->getFullText();
-
…
-
$listmatchs = $HT->getYouthTeamMatches($youtTeamId);
-
$nextMatch = $listmatchs->getNextMatch();
-
echo $nextMatch->getDate() . ' : ' . $nextMatch->getHomeTeamName() . ' - ' . $nextMatch->getAwayTeamName();
-
…
-
$search = $HT->searchTeamByName('CPAM');
-
for($i=1; $i<=$search->getResultNumber(); $i++)
-
{
-
echo $search->getResult($i)->getId() . '<br/>';
-
}
-
…
-
echo $HT->getNationalPlayers($nationalTeamId)->getNumberPlayers() ' players in national team';
-
…
-
?>
You can also put your instance in session and keep datas from page to page.
You can find more examples on how to use PHT, I hope it will help you.
If you find a bug, report it and I will fix it asap. If you have any idea to improve PHT, let me know! Any feedback and thanks are welcome :) I will update PHT each time Hattrick change or update a CHPP page, and I hope it will help you in your application, tell me if you use it, I will add a link to your website.

















Really very nice job.
I will try here and when possible return on feedback.
Congrats, on advance.
[=
Comment par Samurai-BR — 20 mai 2008 à 02:13
excelente trabajo, espero mas ejemplos (sessiones, estadisticas, etc) para poder migrar mi aplicacion a esta herramienta.
excellent work, I hope more examples (Session, statistics, etc.) to migrate my application to this tool.
Comment par destor77 — 23 mai 2008 à 20:04
Very good job. I’ll try it to make my web using PHT.
Thank you!
Comment par Peaso — 26 mai 2008 à 18:41
hi
Comment par arash — 24 juin 2009 à 04:52
isto e muito fixe
Comment par portugal10 — 07 février 2010 à 21:17