Jump to content
xt:Commerce Community Forum

Afterbuy Produkte zu XT:Commerce (3)


Recommended Posts

Mein alter Programmierer hatte mal einen Cronjob laufen, um alle Produkte und deren Lagerbestand von Afterbuy zu XT zu importieren. Der Programmierer hat sich nichtssagend verabschiedet und hat auch den Cronjob abgestellt:eek:. Nun will ich das alles wieder in gang setzen. Ich habe auf dem Server nur mehrere Dateien im Root (afterbuy.php|afterbuy_getp.php) und einen ordner "fromafterbuy" in dem sich .txt dateien befinden.

Ich versuche nun schon den ganzen Tag rauszufinden, wie ich dieses Script richtig benutze... scheinbar klappt da gar nichts...

Hat jemand ne Ahnung? Ist das vielleicht eine Software?:D

INHALT DER "afterbuy.php"


<?
function afterbuy_products(){
global $page,$lastid;

$this->eBayGatewayURL = 'https://www.afterbuy.de/afterbuy/ABInterface.aspx';



$requestXML='
<?xml version="1.0" encoding="utf-8"?>
<Request>
<AfterbuyGlobal>
<PartnerID>xxxxxxx</PartnerID>
<PartnerPassword>xxxxxxx</PartnerPassword>
<UserID>xxxxxxx</UserID>
<UserPassword>xxxxxxx</UserPassword>
<CallName>GetShopProducts</CallName>
<DetailLevel>0</DetailLevel>
<ErrorLanguage>de</ErrorLanguage>
<PageNumber>'.$page.'</PageNumber>
</AfterbuyGlobal>

<MaxShopItems>80</MaxShopItems>
<PaginationEnabled>true</PaginationEnabled>

<DataFilter>
<Filter>
<FilterName>RangeID</FilterName>
<FilterValues>
<ValueFrom>'.$lastid.'</ValueFrom>
</FilterValues>
</Filter>


<Filter>
<FilterName>Level</FilterName>
<FilterValues>
<LevelFrom>0</LevelFrom>
<LevelTo>999</LevelTo>
</FilterValues>
</Filter>
</DataFilter>

</Request>
';



// The cURL request
$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,$this->eBayGatewayURL);

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

//curl_setopt ($ch, CURLOPT_HEADER, 1); // 0 = No Return Header
//curl_setopt($ch, CURLOPT_HTTPHEADER, $ebayHeaders); // Set the eBay Headers
curl_setopt($ch, CURLOPT_POST, 1); // POST Method
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); //My XML Request
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$httpResponse = curl_exec ($ch); //Send the request
curl_close ($ch); // Close the connection

$result= $httpResponse;
$result=UTF8_DECODE($result);
$api=$result;
$lastid=giveme($api,'<LastProductID>','</LastProductID>');

$erg="";
while (strpos($result,'<Product>')){



$a=giveme($result,'<Product>','</Product>');

$desc=giveme($a,'<Description><![CDATA[',']]></Description>');
$desc=str_replace("\n","",$desc);
$desc=str_replace("\r","",$desc);

$erg.= giveme($a,'<ProductID>','</ProductID>').'|';
$erg.=giveme($a,'<Quantity>','</Quantity>').'|';
$erg.=giveme($a,'<Anr>','</Anr>').'|';
$erg.=giveme($a,'<ImageLargeURL><![CDATA[',']]></ImageLargeURL>').'|';
$erg.=str_replace(",",".",giveme($a,'<SellingPrice>','</SellingPrice>')).'|';
$erg.=str_replace(",",".",giveme($a,'<Weight>','</Weight>')).'|';
$erg.=giveme($a,'<Name><![CDATA[',']]></Name>').'|';
$erg.=$desc.'|';
$erg.=giveme($a,'<Level>','</Level>').'|';
$erg.=giveme($a,'<CatalogID>','</CatalogID>').'|';
$erg.=giveme($a,'<TaxRate>','</TaxRate>').'|';

$erg.="\r\n";

$result="aaaa".giveme($result,'</Product>','');


}

$handle=fopen("fromafterbuy/produkte".$page.".txt","w+");
fwrite($handle,$erg);
fclose($handle);
$handle=fopen("fromafterbuy/produkte_api".$page.".txt","w+");
fwrite($handle,$requestXML.$api);
fclose($handle);
if (strpos($api,"<HasMoreProducts>1</HasMoreProducts>")) return 1; else return 0;


echo $erg;
}








function afterbuy_kats(){
global $page,$lastid;
echo $page;

$this->eBayGatewayURL = 'https://www.afterbuy.de/afterbuy/ABInterface.aspx';



$requestXML='
<?xml version="1.0" encoding="utf-8"?>
<Request>
<AfterbuyGlobal>
<PartnerID>2790</PartnerID>
<PartnerPassword>1yfz2gjw</PartnerPassword>
<UserID>*sulani*</UserID>
<UserPassword>thailand789</UserPassword>
<CallName>GetShopCatalogs</CallName>
<DetailLevel>0</DetailLevel>
<ErrorLanguage>DE</ErrorLanguage>
</AfterbuyGlobal>
<MaxCatalogs>100</MaxCatalogs>
</Request>
';



// The cURL request
$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,$this->eBayGatewayURL);

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

//curl_setopt ($ch, CURLOPT_HEADER, 1); // 0 = No Return Header
//curl_setopt($ch, CURLOPT_HTTPHEADER, $ebayHeaders); // Set the eBay Headers
curl_setopt($ch, CURLOPT_POST, 1); // POST Method
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); //My XML Request
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$httpResponse = curl_exec ($ch); //Send the request
curl_close ($ch); // Close the connection

$result= $httpResponse;
$result=UTF8_DECODE($result);
$api=$result;


$erg="";
while (strpos($result,'<Catalog>')){



$a=giveme($result,'<Catalog>','</Catalog>');


$erg.= giveme($a,'<CatalogID>','</CatalogID>').'|';
$erg.=giveme($a,'<Name><![CDATA[',']]></Name>').'|';
$erg.=giveme($a,'<ParentID>','</ParentID>').'|';
$erg.=giveme($a,'<Level>','</Level>').'|';
$erg.=giveme($a,'<Position>','</Position>').'|';
$erg.=giveme($a,'<Show>','</Show>').'|';

$erg.="\r\n";

$result="aaaa".giveme($result,'</Catalog>','');

}


$handle=fopen("fromafterbuy/cats.txt","w+");
fwrite($handle,$erg);
fclose($handle);

return 1;


}









function afterbuy_shipping($sproducts,$scountry,$splz,$sweight,$scount,$sprice){
global $page,$lastid;

$this->eBayGatewayURL = 'https://www.afterbuy.de/afterbuy/ABInterface.aspx';


$requestXML='
<?xml version="1.0" encoding="utf-8"?>
<Request>
<AfterbuyGlobal>
<PartnerID>2790</PartnerID>
<PartnerPassword>1yfz2gjw</PartnerPassword>
<UserID>*sulani*</UserID>
<UserPassword>thailand789</UserPassword>
<CallName>GetShippingCost</CallName>
<DetailLevel>0</DetailLevel>
<ErrorLanguage>DE</ErrorLanguage>
</AfterbuyGlobal>
<ShippingInfo>
<ShippingCountry>'.$scountry.'</ShippingCountry>
<ItemsCount>'.$scount.'</ItemsCount>
<ItemsWeight>'.$sweight.'</ItemsWeight>
<ItemsPrice>'.$sprice.'</ItemsPrice>
<PostalCode>'.$splz.'</PostalCode>
<Products>
'.$sproducts.'
</Products>
</ShippingInfo>
</Request>
';
echo $requestXML;
// The cURL request
$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,$this->eBayGatewayURL);

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

//curl_setopt ($ch, CURLOPT_HEADER, 1); // 0 = No Return Header
//curl_setopt($ch, CURLOPT_HTTPHEADER, $ebayHeaders); // Set the eBay Headers
curl_setopt($ch, CURLOPT_POST, 1); // POST Method
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); //My XML Request
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$httpResponse = curl_exec ($ch); //Send the request
curl_close ($ch); // Close the connection

$result= $httpResponse;
$result=UTF8_DECODE($result);
$api=$result;

return $result;

}







function giveme($aus,$von,$bis)
{
if (strpos($aus,$von)===false)
{
return "";
}
else
{
$russe=substr($aus,strpos($aus,$von)+strlen($von),strlen($aus));
if ($bis!="") $russe=substr($russe,0,strpos($russe,$bis));
return Trim($russe);
}
}
?>

[/PHP]

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...