将 xml 拉入 API 的正确方法是什么?
api代码中的直接xml示例;(这是我们不想要的,我们需要它从文件中提取 xml)
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);
我通过 fopen 引入 xml 的狡猾尝试;
<?
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);
?>
如果有人可以让我们知道如何适当地将 xml 带入 useXML var,请随时分享:)
(应用引号后,代码的某些格式会付清)
谢谢!