xml을 API로 가져 오는 올바른 방법은 무엇입니까?xml을 API로 "가져 오는"올바른 방법은 무엇입니까?
api 코드에서 직선 xml의 예. fopen을 통해 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);
내 사기 시도 (이는 우리가이 파일에서 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);
?>
사람이 우리가 적절하게 useXML의 VAR에 XML을 가지고하는 방법을 알려 수 있다면, :)
(코드의 일부 서식이 적용 따옴표 후 지불) 공유 주시기
감사!
BigCommerce_Api::useXml();
$xml = file_get_contents('xmlfile.xml');
$result = BigCommerce_Api::createBrand($xml);
이 file_get_contents
를 참조하십시오
안녕하세요. SO! 한 가지 팁 : 단문 태그는 사용하지 마십시오 (예 :''대신 ' php' 사용). 그들은 논쟁의 여지가 있습니다. 그리고 그들이 더 이상 사용되지 않을 것이라는 증거가 있습니다. 이 질문, FWIW는 '너무 지역화 된'또는 '진짜 질문이 아님'사이의 토스 - 업입니다. –
[PHP DOM] (http://php.net/manual/en/book.dom.php)을 살펴볼 수 있습니다. –