【问题标题】:XML API IntegrationXML API 集成
【发布时间】:2016-07-03 13:01:30
【问题描述】:

我目前正在做一个酒店预订网站。所以我有一个使用内容管理系统 Magento 制作的网站。我想将它与 XML API 集成。他们为我提供了完整的手动集成内容。但没有解释如何执行此操作。它包含 Web 方法及其 XML。但我不明白将这些代码放在哪里以及如何放置。 我刚刚google了一下,发现堆栈溢出:

 "note.xml"
      <currencies>
     <currency name="US dollar" code_alpha="USD" code_numeric="840" />
         <currency name="Euro" code_alpha="EUR" code_numeric="978" />

      </currencies>
solution
Using DomDocument

<?php
$str = <<<XML
<currencies>
    <currency name="US dollar" code_alpha="USD" code_numeric="840" />
    <currency name="Euro" code_alpha="EUR" code_numeric="978" />
</currencies>
XML;

$dom = new DOMDocument();
$dom->loadXML($str);

foreach($dom->getElementsByTagName('currency') as $currency)
{
    echo $currency->getAttribute('name'), "\n";
    echo $currency->getAttribute('code_alpha'), "\n";
    echo $currency->getAttribute('code_numeric'), "\n";
    echo "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n";
}
?>

Using simplexml:

<?php
$str = <<<XML
<currencies>
    <currency name="US dollar" code_alpha="USD" code_numeric="840" />
    <currency name="Euro" code_alpha="EUR" code_numeric="978" />
</currencies>
XML; 
$currencies = new SimpleXMLElement($str);
foreach($currencies as $currency)
{
    echo $currency['name'], "\n";
    echo $currency['code_alpha'], "\n";
    echo $currency['code_numeric'], "\n";
    echo "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n";
}
?>

但我不明白在哪里以及如何编写这个。执行此操作的过程。 有人可以为我提供执行此操作的链接或互联网上可用的任何详细说明。 我该怎么做? 什么是技术相关的东西(编码),我应该知道这样做吗?

【问题讨论】:

  • 我可以为您指明与 Magento 的原生 API 集成的正确方向,但您能否告诉我您尝试使用上述代码实现的具体结果/结果?
  • 以上代码只是我从堆栈溢出中获得的关于如何将代码从 xml 文档转换为 php 或任何其他代码的示例代码(不确定)。因此,如果我有一个 xml 文档和一个 magento 网站,我只想知道如何进行 xml api 集成(逐步详细信息)。任何提供详细信息的网站链接也将是可观的。提前致谢。

标签: xml api magento


【解决方案1】:

本教程提供了一种基本的“Hello World”方法来创建您自己的 API 端点 - http://code.tutsplus.com/tutorials/create-a-custom-api-in-magento-part-one--cms-23785

如需进一步阅读,总有 Magento 1.x 官方 API 页面(http://devdocs.magento.com/guides/m1x/api/soap/introduction.htmlhttp://devdocs.magento.com/guides/m1x/api/rest/introduction.html)以及真正深入了解,Alan Storm 的文章 (http://alanstorm.com/magento_api_soap_adapaters_and_handlers)

看起来您的端点将提供可用的货币,而用户没有提供任何参数,但这是我的猜测。祝你好运。

【讨论】:

    猜你喜欢
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    • 2014-09-12
    • 2016-07-06
    • 2015-09-11
    • 2011-03-26
    • 2018-02-01
    • 1970-01-01
    相关资源
    最近更新 更多