Visualizzazione dei risultati da 1 a 2 su 2

Discussione: istanza php

  1. #1

    istanza php

    salve io utilizzo questa classe per estrarre tutte le categorie ebay in modo recursivo
    function showNodesCategory($siteId, $Category, $abbr)
    {

    echo $url = 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=' . $this->appID . '&siteid=' . $siteId . '&CategoryID=' . $Category . '&version=729&IncludeSelector=ChildCategories';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url); // get the url contents
    $data = curl_exec($ch); // execute curl request
    curl_close($ch);
    $XMLIT = simplexml_load_string($data);
    //$new = new ebay();
    //$obj = new $this->libCurl($url);
    //$obj2 = clone $obj;
    //$XMLIT = $this->libCurl($url);

    foreach ($XMLIT->CategoryArray->Category as $current) {
    $CategoryID = $current->CategoryID;
    $CategoryLevel = $current->CategoryLevel;
    $CategoryName = $current->CategoryName;
    $CategoryParentID = $current->CategoryParentID;
    $LeafCategory = $current->LeafCategory;
    //echo $abbr.", ".$CategoryParentID.", ".$CategoryID.", ".$CategoryName.", ".$LeafCategory."<br>";
    $this->arrayPath[] = [$abbr, $CategoryParentID, $CategoryID, $CategoryName];


    if ($LeafCategory == "false" AND $CategoryID != "-1") {

    $this->showNodesCategory($siteId, $CategoryID, $abbr);
    }

    }
    //dd($this->arrayPath);
    return $this->arrayPath;
    }

    purtrppo non funziona. e rimane sempre bloccato alla seconda chiamata del metodo.
    senza usare le classi con una semplice funzione va benissimo fatto
    con una funzione tipo questa

    function download_page($path){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$path);
    curl_setopt($ch, CURLOPT_FAILONERROR,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    $retValue = curl_exec($ch);
    curl_close($ch);
    $oXML=simplexml_load_string($retValue);
    //return $retValue;

    foreach($oXML->CategoryArray->Category as $current){
    $conta++;
    $_SESSION['susperContatore']++;
    $CategoryID = $current->CategoryID ;
    $CategoryLevel = $current->CategoryLevel ;
    $CategoryName = $current->CategoryName ;
    $CategoryParentID = $current->CategoryParentID ;
    $LeafCategory = $current->LeafCategory ;
    if($conta>1){
    $_SESSION['valore'].=$_SESSION['susperContatore']." \t ".$CategoryParentID." \t ".$CategoryID." \t ".$CategoryName." \t \t \n";
    }
    if($LeafCategory=="true"){
    $_SESSION['categorieMassive'].=$CategoryID.",";
    }
    if($LeafCategory=="false" AND $CategoryID!="-1" AND $conta>1){
    $url= 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=supporto-375a-4934-99d2-3c5288782a10&siteid=101&CategoryID='.$CategoryID.'&version=729&IncludeSelector=ChildCategories';
    download_page($url);
    }

    }

    }

    volevo riproporre lo stesso sistema con oop ma non so come fare. grazie

  2. #2
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    se aggiungi una traccia. Quante volte apparre ?

    Codice PHP:
    if (LeafCategory == "false" AND $CategoryID != "-1") {
       echo 
    "Passo di qua<br/>";
      
    $this->showNodesCategory($siteId$CategoryID$abbr);

    Ridatemi i miei 1000 posts persi !!!!
    Non serve a nulla ottimizzare qualcosa che non funziona.
    Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.