Here is the method provide by Volusion support for ProductSync but the code in C# i want to implement in PHP but how to implement it i don't know.
https://support.volusion.com/hc/en-us/articles/209637767-API-Integration-ProductSync-Developer-
So anyone can help me that how to implement in PHP because i am working on PHP i have no knowledge of C#. I just copy this code in paste in my PHP it give me an error like this
Fatal error: Class 'XMLHTTP' not found in /home/tlztech/public_html/volusion/productSync.php on line 5.
And my code as under.
<?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;
?>
</div>
I think it's because you need to use namespace of you're XMLHTTP class :
$xml_http = new Your\Namespace\XMLHTTP();
because there is no XMLHTTP class in your file. That's why it is not found
Then if you want to use only XMLHTTP()
you need to add a use at the beginning of your file:
use <NAMESPACE>;
If this class is from the global namespace just do it like that : $xml_http = new \XMLHTTP();
You're trying to reference a Microsoft class that doesn't exist in PHP.
I see in your other recent threads that you've tried to call the Volusion API with cURL. This is a valid approach that I use with PHP. There's no need to adapt the C# example into PHP.
Here is a valid example in PHP using cURL and your URL example:
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&Import=Update";
$api_request = '<?xml version="1.0" encoding="utf-8" ?>';
$api_request .= '<xmldata>';
$api_request .= ' <Products>';
$api_request .= ' <ProductCode>0001</ProductCode>';
$api_request .= ' <StockStatus>5</StockStatus>';
$api_request .= ' </Products>';
$api_request .= '</xmldata>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_request);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
$head = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);