What would be the correct way to pull the xml, into the API?
Example of straight xml in the api code; ( which is what we dont want, we need it to pull the xml from a file )
BigCommerce_Api::useXml();
$xml = "<?xml version="1.0" encoding="UTF-8"?>
<brand>
<name>Apple</name>
<search_keywords>computers laptops</search_keywords>
</brand>";
$result = BigCommerce_Api::createBrand($xml);
My dodgy attempt at bringing in the xml via fopen;
<?
require_once 'BigCommerce/Api.php';
BigCommerce_Api::configure(array(
'store_url' => 'https://apiurl',
'username' => 'admin',
'api_key' => 'apitoken'
));
$filename = "xmlfile.xml";
$handle = fopen($filename, "r");
$XPost = fread($handle, filesize($filename));
fclose($handle);
BigCommerce_Api::useXml();
$xml = $XPost;
$result = BigCommerce_Api::createProduct($xml);
?>
If anyone could let us know how to bring the xml into the useXML var appropriately, feel free to share 🙂
( some of the formatting of the code is paying up after quotes applied )
Thanks!
I have no idea why you make your life that complicated:
See
file_get_contents.