recordcount = 0; $fp = fopen ($wsurl, "r"); if ($fp) { $xml = ""; while ($data=fgets($fp, 32000)) $xml .= $data; fclose ($fp); $this->xml = $xml; } else return ""; return $xml; } function parse () { $items = $this->extractstring ($this->xml, ""); if ($items) { $i = 0; $item = $this->extractall ($items, "", ""); $n = count ($item); //echo $n; for ($i=0; $i<$n; $i++) { $offerTitle = $this->extractstring ($item[$i], "", ""); $merchantURL = $this->extractstring ($item[$i], "", ""); $this->item[$i] = new KelkooItem; $trans = array(" "", "]]>" => ""); $this->item[$i]->kelkoo_title = strtr($offerTitle, $trans); $this->item[$i]->kelkoo_url = strtr($merchantURL, $trans); $this->recordcount++; } } return $this->recordcount; } function extractall ($xml, $tag1, $tag2) { $ok = true; $i = 0; while ($ok==true) { $i1 = strpos($xml, $tag1); $i2 = strpos($xml, $tag2); if ( ($i1!==false) && ($i2!==false) ) { //echo $i1 . " / " . $i2 . " - "; $i1 = $i1 + strlen ($tag1); $len = $i2 - $i1; $data[$i] = substr ($xml, $i1, $len); $xml = substr ($xml, $i2+strlen($tag2), strlen($xml)); //echo "
" . htmlentities($data[$i]) . "
\n\n\n"; $i++; } else $ok = false; } return $data; } function extractstring ($xml, $tag1, $tag2) { $i1 = strpos($xml, $tag1); $i2 = strpos($xml, $tag2); if ( ($i1!==false) && ($i2!==false) ) { $i1 = $i1 + strlen ($tag1); $len = $i2 - $i1; $data = substr ($xml, $i1, $len); } else $data = ""; return $data; } function search_by_keyword ($keyword) { //$wsurl = "http://webservices.amazon.fr/onca/xml?Service=AWSECommerceService&SubscriptionId=" . $this->subscriptionID . "&Operation=ItemSearch&SearchIndex=" . $this->itemtype . "&Keywords=" . $keyword . "&ResponseGroup=Medium,OfferFull"; //$wsurl = "kelkoo.xml"; $wsurl = "http://export.kelkoo.fr/ctl/exportSearch?partner=photosvoyage&siteSearchQuery=corse&partnerId=96906075"; $this->load ($wsurl); if (strpos($this->xml, "parse(); $ok = true; } else { $this->error = "Error"; $ok = false; } return $ok; } }; // ========================= // ========================= ?>