Código PHP:
/**
* Retrieve specified match.
*
* @access public
* @param string MatchID
* @param bool isYouth
*/
function getMatchXML($id, $isYouth = false)
{
$form = array();
if ($id)
$form['matchID'] = $id;
if ($isYouth)
$form['isYouth'] = $isYouth;
$params = "";
foreach($form as $key => $value)
{
$params .= "&" . $key . "=" . $value;
}
$code = $this->http->get(HT_CHPP_MATCHDETAILS . $params, 'http://'.$this->http->host.HT_CHPP_HOME);
if ($code != 200)
return false;
return $this->http->get_response_body();
}
/**
* Retrieve specified match.
*
* @access public
* @param string MatchID
*/
function getMatch($id = false,$isYouth = false)
{
$xml = $this->getMatchXML($id);
if ($xml) {
$parser = xml_parser_create();
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
if (! $vals[$index['FILENAME'][0]]['value'])
return false;
for ($i = 0; $i < count($index['SCORERPLAYERID']); $i++) {
$goal[$i] = array(
'SCORERPLAYERID' => $vals[$index['SCORERPLAYERID'][$i]]['value'],
'SCORERPLAYERNAME' => $vals[$index['SCORERPLAYERNAME'][$i]]['value'],
'SCORERTEAMID' => $vals[$index['SCORERTEAMID'][$i]]['value'],
'SCORERHOMEGOALS' => $vals[$index['SCORERHOMEGOALS'][$i]]['value'],
'SCORERAWAYGOALS' => $vals[$index['SCORERAWAYGOALS'][$i]]['value'],
'SCORERMINUTE' => $vals[$index['SCORERMINUTE'][$i]]['value']
);
}
for ($i = 0; $i < count($index['BOOKINGPLAYERID']); $i++) {
$booking[$i] = array(
'BOOKINGPLAYERID' => $vals[$index['BOOKINGPLAYERID'][$i]]['value'],
'BOOKINGPLAYERNAME' => $vals[$index['BOOKINGPLAYERNAME'][$i]]['value'],
'BOOKINGTEAMID' => $vals[$index['BOOKINGTEAMID'][$i]]['value'],
'BOOKINGTYPE' => $vals[$index['BOOKINGTYPE'][$i]]['value'],
'BOOKINGMINUTE' => $vals[$index['BOOKINGMINUTE'][$i]]['value']
);
}
$match = array(
'FILENAME' => $vals[$index['FILENAME'][0]]['value'],
'VERSION' => $vals[$index['VERSION'][0]]['value'],
'USERID' => $vals[$index['USERID'][0]]['value'],
'FETCHEDDATE' => $vals[$index['FETCHEDDATE'][0]]['value'],
'MATCHID' => $vals[$index['MATCHID'][0]]['value'],
'MATCHDATE' => $vals[$index['MATCHDATE'][0]]['value'],
'FINISHEDDATE' => $vals[$index['FINISHEDDATE'][0]]['value'],
'HOMETEAMID' => $vals[$index['HOMETEAMID'][0]]['value'],
'HOMETEAMNAME' => $vals[$index['HOMETEAMNAME'][0]]['value'],
'HOMEGOALS' => $vals[$index['HOMEGOALS'][0]]['value'],
'HOMETEAM' => array(
'DRESS' => $vals[$index['DRESS'][0]]['value'],
'TACTICTYPE' => $vals[$index['TACTICTYPE'][0]]['value'],
'TACTICSKILL' => $vals[$index['TACTICSKILL'][0]]['value'],
'RATINGMIDFIELD' => $vals[$index['RATINGMIDFIELD'][0]]['value'],
'RATINGRIGHTDEF' => $vals[$index['RATINGRIGHTDEF'][0]]['value'],
'RATINGMIDDEF' => $vals[$index['RATINGMIDDEF'][0]]['value'],
'RATINGLEFTDEF' => $vals[$index['RATINGLEFTDEF'][0]]['value'],
'RATINGRIGHTATT' => $vals[$index['RATINGRIGHTATT'][0]]['value'],
'RATINGMIDATT' => $vals[$index['RATINGMIDATT'][0]]['value'],
'RATINGLEFTATT' => $vals[$index['RATINGLEFTATT'][0]]['value'],
'TEAMATTITUDE' => $vals[$index['TEAMATTITUDE'][0]]['value']
),
'AWAYTEAMID' => $vals[$index['AWAYTEAMID'][0]]['value'],
'AWAYTEAMNAME' => $vals[$index['AWAYTEAMNAME'][0]]['value'],
'AWAYGOALS' => $vals[$index['AWAYGOALS'][0]]['value'],
'AWAYTEAM' => array(
'DRESS' => $vals[$index['DRESS'][1]]['value'],
'TACTICTYPE' => $vals[$index['TACTICTYPE'][1]]['value'],
'TACTICSKILL' => $vals[$index['TACTICSKILL'][1]]['value'],
'RATINGMIDFIELD' => $vals[$index['RATINGMIDFIELD'][1]]['value'],
'RATINGRIGHTDEF' => $vals[$index['RATINGRIGHTDEF'][1]]['value'],
'RATINGMIDDEF' => $vals[$index['RATINGMIDDEF'][1]]['value'],
'RATINGLEFTDEF' => $vals[$index['RATINGLEFTDEF'][1]]['value'],
'RATINGRIGHTATT' => $vals[$index['RATINGRIGHTATT'][1]]['value'],
'RATINGMIDATT' => $vals[$index['RATINGMIDATT'][1]]['value'],
'RATINGLEFTATT' => $vals[$index['RATINGLEFTATT'][1]]['value'],
'TEAMATTITUDE' => $vals[$index['TEAMATTITUDE'][1]]['value']
),
'ARENAID' => $vals[$index['ARENAID'][0]]['value'],
'ARENANAME' => $vals[$index['ARENANAME'][0]]['value'],
'WEATHERID' => $vals[$index['WEATHERID'][0]]['value'],
'SOLDTOTAL' => $vals[$index['SOLDTOTAL'][0]]['value'],
'SOLDTERRACES' => $vals[$index['SOLDTERRACES'][0]]['value'],
'SOLDBASIC' => $vals[$index['SOLDBASIC'][0]]['value'],
'SOLDROOF' => $vals[$index['SOLDROOF'][0]]['value'],
'SOLDVIP' => $vals[$index['SOLDVIP'][0]]['value'],
'GOAL' => $goal,
'BOOKING' => $booking
);
return $match;
}
else return false;
}
/**
* Retrieve specified match lineup.
*
* @access public
* @param string MatchID
* @param string TeamID
* @param bool isYouth
*/
function getMatchLineupXML($matchid = false, $teamid = false, $isYouth = false)
{
$form = array('outputType' => 'XML',
'actionType' => 'view'
);
if ($matchid)
$form['matchID'] = $matchid;
if ($teamid)
$form['teamID'] = $teamid;
if ($isYouth)
$form['isYouth'] = $isYouth;
$params = "";
foreach($form as $key => $value)
{
$params .= "&" . $key . "=" . $value;
}
$code = $this->http->get(HT_CHPP_MATCHLINEUP . $params, 'http://'.$this->http->host.HT_HOME);
if ($code != 200)
return false;
return $this->http->get_response_body();
}
/**
* Retrieve specified match lineup.
*
* @access public
* @param string MatchID
* @param string TeamID
* @param bool isYouth
*/
function getMatchLineup($matchid = false, $teamid = false, $isYouth = false)
{
$xml = $this->getMatchLineupXML($matchid, $teamid, $isYouth);
if ($xml) {
$parser = xml_parser_create();
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
if (! $vals[$index['FILENAME'][0]]['value'])
return false;
for ($i = 0; $i < count($index['PLAYERID']); $i++) {
$player[$i] = array(
'PLAYERID' => $vals[$index['PLAYERID'][$i]]['value'],
'ROLEID' => $vals[$index['ROLEID'][$i]]['value'],
'PLAYERNAME' => $vals[$index['PLAYERNAME'][$i]]['value'],
'RATINGSTARS' => $vals[$index['RATINGSTARS'][$i]]['value'],
'POSITIONCODE' => $vals[$index['POSITIONCODE'][$i]]['value'],
'BEHAVIOUR' => $vals[$index['BEHAVIOUR'][$i]]['value']
);
}
$match = array(
'FILENAME' => $vals[$index['FILENAME'][0]]['value'],
'VERSION' => $vals[$index['VERSION'][0]]['value'],
'USERID' => $vals[$index['USERID'][0]]['value'],
'FETCHEDDATE' => $vals[$index['FETCHEDDATE'][0]]['value'],
'MATCHID' => $vals[$index['MATCHID'][0]]['value'],
'HOMETEAMID' => $vals[$index['HOMETEAMID'][0]]['value'],
'HOMETEAMNAME' => $vals[$index['HOMETEAMNAME'][0]]['value'],
'AWAYTEAMID' => $vals[$index['AWAYTEAMID'][0]]['value'],
'AWAYTEAMNAME' => $vals[$index['AWAYTEAMNAME'][0]]['value'],
'MATCHTYPE' => $vals[$index['MATCHTYPE'][0]]['value'],
'ARENAID' => $vals[$index['ARENAID'][0]]['value'],
'ARENANAME' => $vals[$index['ARENANAME'][0]]['value'],
'MATCHDATE' => $vals[$index['MATCHDATE'][0]]['value'],
'TEAMID' => $vals[$index['TEAMID'][0]]['value'],
'TEAMNAME' => $vals[$index['TEAMNAME'][0]]['value'],
'EXPERIENCELEVEL' => $vals[$index['EXPERIENCELEVEL'][0]]['value'],
'PLAYER' => $player
);
return $match;
}
else return false;
}
function getLiveMatchXML($id, $actionType = 'view', $isYouth = false)
{
$actions = array('view','viewNew','viewAll','clearAll','addMatch','deleteMatch');
$form = array();
if ($id)
$form['matchID'] = $id;
if (in_array($actionType, $actions))
$form['actionType'] = $actionType;
else
$form['actionType'] = 'viewNew';
if ($isYouth)
$form['isYouth'] = $isYouth;
$params = "";
foreach($form as $key => $value)
{
$params .= "&" . $key . "=" . $value;
}
$code = $this->http->get(HT_CHPP_LIVE, $params, 'http://'.$this->http->host.HT_HOME);
if ($code != 200)
return false;
return $this->http->get_response_body();
}
/**
* Retrieve specified match description, suitable to for finished matches.
*
* @access public
* @param string MatchID
*/
function getLiveMatch($id, $actionType = 'view', $isYouth = false)
{
$xml = $this->getLiveMatchXML($id, $actionType, $isYouth);
if ($xml) {
$parser = xml_parser_create();
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
if (! $vals[$index['FILENAME'][0]]['value'])
return false;
for ($i = 0; $i < count($index['EVENTKEY']); $i++) {
$event[$i] = array(
'SUBJECTPLAYERID' => $vals[$index['SUBJECTPLAYERID'][$i]]['value'],
'SUBJECTTEAMID' => $vals[$index['SUBJECTTEAMID'][$i]]['value'],
'OBJECTPLAYERID' => $vals[$index['OBJECTPLAYERID'][$i]]['value'],
'MINUTE' => $vals[$index['MINUTE'][$i]]['value'],
'EVENTKEY' => $vals[$index['EVENTKEY'][$i]]['value'],
'EVENTTEXT' => $vals[$index['EVENTTEXT'][$i]]['value']
);
}
$match = array(
'FILENAME' => $vals[$index['FILENAME'][0]]['value'],
'VERSION' => $vals[$index['VERSION'][0]]['value'],
'USERID' => $vals[$index['USERID'][0]]['value'],
'FETCHEDDATE' => $vals[$index['FETCHEDDATE'][0]]['value'],
'MATCHID' => $vals[$index['MATCHID'][0]]['value'],
'MATCHDATE' => $vals[$index['MATCHDATE'][0]]['value'],
'HOMETEAMID' => $vals[$index['HOMETEAMID'][0]]['value'],
'HOMETEAMNAME' => $vals[$index['HOMETEAMNAME'][0]]['value'],
'AWAYTEAMID' => $vals[$index['AWAYTEAMID'][0]]['value'],
'AWAYTEAMNAME' => $vals[$index['AWAYTEAMNAME'][0]]['value'],
'EVENT' => $event
);
return $match;
}
else return false;
}