这是 Volusion 支持 ProductSync 提供的方法,但我想用 PHP 实现 C# 中的代码,但我不知道如何实现它。
https://support.volusion.com/hc/en-us/articles/209637767-API-Integration-ProductSync-Developer-
所以任何人都可以帮助我如何在 PHP 中实现,因为我正在研究 PHP,我不了解 C#。我只是将此代码复制粘贴到我的 PHP 中,它给了我这样的错误
致命错误:在第 5 行的 /home/tlztech/public_html/volusion/productSync.php 中找不到类“XMLHTTP”。
我的代码如下。
<?php
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&API_Name=Generic\\Products&SELECT_Columns=p.ProductCode,p.ProductID,p.ProductName,p.StockStatus";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.send(null);
$api_response = $xml_http.responseText;
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&Import=Update";
$api_request = "";
$api_request = $api_request + "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$api_request = $api_request + "<xmldata>";
$api_request = $api_request + " <Products>";
$api_request = $api_request + " <ProductCode>0001</ProductCode>";
$api_request = $api_request + " <StockStatus>5</StockStatus>";
$api_request = $api_request + " </Products>";
$api_request = $api_request + "</xmldata>";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
$xml_http.setRequestHeader("Content-Action", "Volusion_API");
$xml_http.send(api_request);
$xml_http = $xml_http.responseText;
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&API_Name=Generic\\Products&SELECT_Columns=p.ProductCode,p.ProductID,p.ProductName,p.StockStatus&WHERE_Column=p.ProductCode&WHERE_Value=0002";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.send(null);
$api_response = $xml_http.responseText;
?>