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