Plan du site Flux RSS Contactez-moi

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:

<?php
  1. try
  2. {
  3.   $HT = new CHPPConnection('chppName', 'chppId', 'chppKey');
  4.   if($HT->connectUser('user-login', 'user-security-code'))
  5.   {
  6.     echo $HT->getClub()->getTeamname() . '(' . $HT->getClub()->getTeamId() . ')';
  7.     $HT->disconnect();
  8.   }
  9.   else
  10.   {
  11.     echo "Login error !";
  12.   }
  13. }
  14. catch(HTError $e)
  15. {
  16.   // Hattrick is down ? See exception message, error code, request, …
  17. }
  18. ?>

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:

<?php
  1. $team = $HT->getTeam();
  2. if($team->isHtSupporter())
  3. {
  4.   echo $team->getPressAnnouncementDate() . ' - ' . $team->getPressAnnouncementTitle() . '<br/>' . $team->getPressAnnouncementText();
  5. }
  6. $match = $HT->getSeniorMatchDetails($matchId);
  7. echo $match->getScore();
  8. echo $match->getFullText();
  9. $listmatchs = $HT->getYouthTeamMatches($youtTeamId);
  10. $nextMatch = $listmatchs->getNextMatch();
  11. echo $nextMatch->getDate() . ' : ' . $nextMatch->getHomeTeamName() . ' - ' . $nextMatch->getAwayTeamName();
  12. $search = $HT->searchTeamByName('CPAM');
  13. for($i=1; $i<=$search->getResultNumber(); $i++)
  14. {
  15.   echo $search->getResult($i)->getId() . '<br/>';
  16. }
  17. echo $HT->getNationalPlayers($nationalTeamId)->getNumberPlayers() ' players in national team';
  18. ?>

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.

Ces icônes sont des liens vers des sites de partage de signet sociaux où les lecteurs peuvent partager et découvrir de nouveaux liens.
  • Yoolink
  • Scoopeo
  • bodytext
  • del.icio.us
  • Facebook
  • TwitThis
  • Wikio FR
  • StumbleUpon
  • Technorati
  • Slashdot
  • Google
  • Live
  • E-mail this story to a friend!
  • Print this article!
  1. 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

  2. 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

  3. Very good job. I’ll try it to make my web using PHT.
    Thank you!

    Comment par Peaso — 26 mai 2008 à 18:41

  4. hi

    Comment par arash — 24 juin 2009 à 04:52

  5. isto e muito fixe

    Comment par portugal10 — 07 février 2010 à 21:17

Laisser un commentaire

  1. * Commentaire :

  2. * Recopiez le code :