Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

como llamar a esta funcion...

Estas en el tema de como llamar a esta funcion... en el foro de Frameworks y PHP orientado a objetos en Foros del Web. hola tengo una clase que tiene estas funciones: Código PHP: require_once  'http.inc' ; ... define ( 'HT_CHPP_MATCHES' ,  '/Common/chpp/chppxml.axd?file=matches' ); define ( 'HT_CHPP_MATCHESARCHIVE' ,  '/Common/chpp/chppxml.axd?file=matchesarchive' ...
  #1 (permalink)  
Antiguo 29/02/2008, 06:18
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
como llamar a esta funcion...

hola tengo una clase que tiene estas funciones:
Código PHP:
require_once 'http.inc';
...
define('HT_CHPP_MATCHES''/Common/chpp/chppxml.axd?file=matches');
define('HT_CHPP_MATCHESARCHIVE''/Common/chpp/chppxml.axd?file=matchesarchive');
define('HT_CHPP_MATCHLINEUP''/Common/chpp/chppxml.axd?file=matchlineup');
define('HT_CHPP_MATCHDETAILS''/Common/chpp/chppxml.axd?file=matchdetails');
define('HT_CHPP_LIVE','/Common/chpp/chppxml.axd?file=live');
...
class 
HTClient
{....
/**
 * Matches archive information
 * @var array
 */
var $matchesArchive;

/**
 * Retrieve matches archive for team $id, or for user's own team.
 *
 * @param    string   teamID
 * @access   public
 */
function getMatchesArchiveXML($id false$first false$last false$isYouth false$season false) {

    
$form = array();
    if (
$id)
        
$form['teamID'] = $id;
    if (
$first)
        
$form['FirstMatchDate'] = $first;
    if (
$last)
        
$form['LastMatchDate'] = $last;
    if (
$isYouth)
        
$form['isYouth'] = $isYouth;
    if (
$season)
        
$form['Season'] = $season;

    
$params "";
    foreach(
$form as $key => $value)
    {
        
$params .= "&" $key "=" $value;
    }

    
$code $this->http->get(HT_CHPP_MATCHESARCHIVE $params'http://'.$this->http->host.HT_HOME);

    if (
$code != 200)
        return 
false;
    return 
$this->http->get_response_body();
}

/**
 * Retrieve matches archive for team $id, or for user's own team.
 *
 * @param    string   teamID
 * @access   public
 */
function getMatchesArchive($id false$first false$last false$isYouth false$season false) {
    if ((! 
$id) && ($this->matchesArchive))
        return 
$this->matchesArchive;
    
$xml $this->getMatchesArchiveXML($id$first$last$isYouth$season);

    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 
$xml;
        for (
$i 0$i count($index['MATCHID']); $i++) {
            
$match[$i] = array(
                
'MATCHID' => $vals[$index['MATCHID'][$i]]['value'],
                
'HOMETEAMID' => $vals[$index['HOMETEAMID'][$i]]['value'],
                
'HOMETEAMNAME' => $vals[$index['HOMETEAMNAME'][$i]]['value'],
                
'AWAYTEAMID' => $vals[$index['AWAYTEAMID'][$i]]['value'],
                
'AWAYTEAMNAME' => $vals[$index['AWAYTEAMNAME'][$i]]['value'],
                
'MATCHDATE' => $vals[$index['MATCHDATE'][$i]]['value'],
                
'MATCHTYPE' => $vals[$index['MATCHTYPE'][$i]]['value'],
                
'HOMEGOALS' => $vals[$index['HOMEGOALS'][$i]]['value'],
                
'AWAYGOALS' => $vals[$index['AWAYGOALS'][$i]]['value']
            );
        }
        
$this->matchesArchive = 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'],
            
'TEAMID' => $vals[$index['TEAMID'][0]]['value'],
            
'TEAMNAME' => $vals[$index['TEAMNAME'][0]]['value'],
            
'FIRSTMATCHDATE' => $vals[$index['FIRSTMATCHDATE'][0]]['value'],
            
'LASTMATCHDATE' => $vals[$index['LASTMATCHDATE'][0]]['value'],
            
'MATCH' => $match
        
);
        return 
$this->matchesArchive;
    }
    else return 
false;
}
..... 
yo la estoy llamando asi:
Código PHP:
$partido $htclient->getLiveMatch($_GET['id'],'view','false'); 
pero no me devuelve nada no se si estoy haciendo bien la llamada.
  #2 (permalink)  
Antiguo 29/02/2008, 06:54
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 20 años, 4 meses
Puntos: 89
Re: como llamar a esta funcion...

Pues por lo que veo en el código, no hay ninguna función que se llame getLiveMatch =/
  #3 (permalink)  
Antiguo 29/02/2008, 07:13
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: como llamar a esta funcion...

perdón puse las funciones incorrectas

el código es este:
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;

  #4 (permalink)  
Antiguo 29/02/2008, 08:51
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: como llamar a esta funcion...

Por lo que veo la función te puede regresar false, por lo que si lo quieres imprimir por echo no te saldrá, prueba hacer esto:
Código PHP:
$partido $htclient->getLiveMatch($_GET['id'],'view','false');
var_dump$partido ); 
Saludos.
  #5 (permalink)  
Antiguo 29/02/2008, 09:08
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: como llamar a esta funcion...

me devuelve esto:
Código PHP:
array(11) { ["FILENAME"]=>  string(8"live.xml" ["VERSION"]=>  string(3"1.3" ["USERID"]=>  string(6"499303" ["FETCHEDDATE"]=>  string(19"2008-02-29 15:55:09" ["MATCHID"]=>  NULL ["MATCHDATE"]=>  NULL ["HOMETEAMID"]=>  NULL ["HOMETEAMNAME"]=>  NULL ["AWAYTEAMID"]=>  NULL ["AWAYTEAMNAME"]=>  NULL ["EVENT"]=>  NULL 

Última edición por destor77; 29/02/2008 a las 09:59
  #6 (permalink)  
Antiguo 29/02/2008, 09:44
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: como llamar a esta funcion...

Al parecer si te esta devolviendo el dato correcto, tienes que ya luego parsear tu los datos a como los necesites.

Saludos.
  #7 (permalink)  
Antiguo 29/02/2008, 10:13
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: como llamar a esta funcion...

el tema es que no me tiene que devolver null estos datos

["MATCHID"]=> NULL ["MATCHDATE"]=> NULL ["HOMETEAMID"]=> NULL ["HOMETEAMNAME"]=> NULL ["AWAYTEAMID"]=> NULL ["AWAYTEAMNAME"]=> NULL ["EVENT"]=> NULL }

al parecer no me esta tomando el $_GET[id], porque en otra funcion que tambien tengo que pasar el $_GET[id] $detalle = $htclient->getMatch($_GET['id'],'false');
me devuelve los resultados, muy raro...
  #8 (permalink)  
Antiguo 29/02/2008, 10:28
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: como llamar a esta funcion...

Prueba usar echo $_GET['id'] antes de llamar a la función y verifica que el dato este correcto.

Saludos.
  #9 (permalink)  
Antiguo 29/02/2008, 11:13
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: como llamar a esta funcion...

este es en el enlace donde paso el id:
http://localhost/chpp/partido.php?id=159508899

y en el archivo partido cuando hago el echo del get me devuelve 159508899, asi que ya estoy totalmente despistado
  #10 (permalink)  
Antiguo 01/03/2008, 15:48
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: como llamar a esta funcion...

El problema puede ser que los datos de donde lees el XML no tenga ese ID.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:16.