【问题标题】:posting data from magento to a SOAP API将数据从 magento 发布到 SOAP API
【发布时间】:2018-02-09 16:46:23
【问题描述】:
我有一个观察者事件,该事件在客户详细信息更新时随时捕获。此时,它将该信息发布到 var 日志中。
我想让它发布到 SOAP API url。
SOAP API URL
在这一点上,我试图指出如何做到这一点的正确方向,我相信我需要将信息写入与 API 匹配的 XML。
我只有 6 个字段需要填写,所以我认为不会很难。
$fon = $billingaddress->getTelephone();
$street1 = $billingaddress->getStreet(1);
$street2 = $billingaddress->getStreet(2);
$city = $billingaddress->getCity();
$region = $billingaddress->getRegion();
$postcode = $billingaddress->getPostcode();
电话号码兼作客户#
有人可以帮我编写 XML 的代码吗?
【问题讨论】:
标签:
php
xml
web-services
magento
soap
【解决方案1】:
这个块将进入你的身体标签,如示例HERE 所示。对于 XML,它非常简单,您可以将其作为一个 $request 变量而不是分配多个:
<?php
$request = '<UpdateCustomer xmlns="http://www.dpro.com/DPAPIServices">'.
'<aRequest>'.
// '<Username>'..'</Username>'.
// '<Password>'..'</Password>'.
'<CustomerNumber>'.$billingaddress->getTelephone();.'</CustomerNumber>'.
'<CustomerName>'.$billingAddress->getFirstname().' '.$billingAddress->getLastname().'</CustomerName>'.
'<CustomerAddress1>'.$billingaddress->getStreet(1).'</CustomerAddress1>'.
'<CustomerAddress2>'.$billingaddress->getStreet(2).'</CustomerAddress2>'.
'<CustomerCity>'.$billingaddress->getCity().'</CustomerCity>'.
'<CustomerState>'.$billingaddress->getRegion().'</CustomerState>'.
'<CustomerZip>'.$billingaddress->getPostcode().'</CustomerZip>'.
'</aRequest>'.
'</UpdateCustomer>';
?>
注意:
我注释掉了 Username 和 Password 因为它们没有包含在您的示例中,并且我不确定它们是您的 API 用户的凭据还是与客户相关。