/**
* Example class for Swiss-Volley Web Service
*
*/
class SoapExample {
/**
* The SoapClient instance
*
* @var SoapClient
*/
private $obj_soap;
/**
* Connects to Soap-Server
*
* @throws SoapFault
* @param string $str_wsdlfile
*/
public function connect($str_wsdlfile){
$this->obj_soap = new SoapClient($str_wsdlfile);
}
/**
* Returns the league overview with its groups. This method should
* be cached. Because this operations are time-critical and the returned
* values cache only once a season.
*
* @param string $str_keyword
* @throws SoapFault
* @return array
*/
public function getLeagues($str_keyword){
$arr_ret = array();
$arr_leagues = $this->obj_soap->getLeagues($str_keyword);
foreach ($arr_leagues as $arr_current_league){
$currentLeague =& $arr_ret[$arr_current_league->Gender][$arr_current_league->league_ID];
$currentLeague[„caption“] = utf8_decode($arr_current_league->Caption);
$arr_phases = $this->obj_soap->getPhases($arr_current_league->league_ID);
foreach ($arr_phases as $arr_current_phase){
$currentPhase =& $currentLeague[„phases“][$arr_current_phase->phase_ID];
$currentPhase[„caption“] = utf8_decode($arr_current_phase->Caption);
$arr_groups = $this->obj_soap->getGroups($arr_current_phase->phase_ID);
foreach ($arr_groups as $arr_current_group){
$currentGroup =& $currentPhase[„groups“][$arr_current_group->group_ID];
$currentGroup = utf8_decode($arr_current_group->Caption);
}
}
}
return $arr_ret;
}
/**
* Return a overview of the given group
*
* @param int $group_ID The unique id of the group.
*/
public function getGroupOverview ($group_ID){
require_once(„Date.php“);
// More information of this group
$arr_groupInfo = $this->obj_soap->getGroupDetailed($group_ID);
// @todo do something with $arr_groupInfo for example return it or display it
// Games of a datespan of this group
$obj_dateStart = new Date(time());
$obj_dateEnd = new Date(strtotime(„+3 week“));
$arr_gamesDateSpan = $this->obj_soap->getGamesDateSpan(
$group_ID,
$obj_dateStart->getDate(),
$obj_dateEnd->getDate()
);
// @todo do something with $arr_gamesDateSpan for example return it or display it
// Current Table (Ranking) of this group
$arr_table = $this->obj_soap->getTable($group_ID);
// @todo do something with $arr_table for example return it or display it
}
/**
* Return all games of a date span.
*
* @param string $keyword The keyword of the league (for example „NATIONAL“)
* @return array
*/
public function getNextGames($keyword){
require_once(„Date.php“);
$obj_dateStart = new Date(time());
$obj_dateEnd = new Date(strtotime(„+3 week“));
return $this->obj_soap->getGamesDateSpanAllGroups(
$keyword,
$obj_dateStart->getDate(),
$obj_dateEnd->getDate()
);
}
}
// Exceptions must be catched!!!
$obj_example = new SoapExample();
// Connect to the server
$obj_example->connect(„http://myvolley.volleyball.ch/SwissVolley.wsdl“);
// Get overview
$arr_leagues = $obj_example->getLeagues(„NATIONAL“);
/*
Now we have all leagues and groups with its captions and genders
Group 28 for example is: NLB – f – Vorrunde – Ost
*/
$group_ID = 28;
// All information of this group
$str_groupOverview = $obj_example->getGroupOverview($group_ID);
// We can also retrieve all next games
$arr_gamesLeague = $obj_example->getNextGames(„NATIONAL“);
?>