Webhook XML 始终为空



我正在使用递归网络钩子来更新联系人,但XML总是空的,这是我尝试过的:

$xmlString = file_get_contents('php://input');
$dom = new DomDocument();
$dom->loadXML($xmlString);

但是,当我查看文件时,它始终为空:

$rsn = $dom->getElementsByTagName('successful_payment_notification');
if($rsn->length != 0){
  //.. do something
}

但我注意到$dom总是空的,这是 XML 递归发送的内容:

<?xml version="1.0" encoding="UTF-8"?>
<successful_payment_notification>
  <account>
    <account_code>89728427a3caa0b21b2ds31223c0fad6f443b82</account_code>
    <first_name>Michael</first_name>
    <last_name>Scott</last_name>
    <company_name nil="true"></company_name>
    <phone nil="true"></phone>
  </account>
  <transaction>
    <id>467fc116288ab89c8d7c954bbca565a8</id>
    <invoice_id>467fc11613dcd438d4410c4ca0bc03e8</invoice_id>
    <invoice_number_prefix></invoice_number_prefix>
    <invoice_number type="integer">1379</invoice_number>
    <test type="boolean">false</test>
    <voidable type="boolean">false</voidable>
    <refundable type="boolean">true</refundable>
  </transaction>
</successful_payment_notification>

allow_url_fopen 已打开,不确定可能导致此问题的原因,我正在使用 AWS Lightsail 和 Bitnami。

我已经找到了答案,我把它改成这样:

$xml = new SimpleXMLElement(file_get_contents('php://input'));
$data = json_decode(json_encode($xml), true);
switch ($xml->getName()) {
    case "renewed_subscription_notification":
        sendEmail("renewed_subscription_notification");
        break;
}

相关内容

  • 没有找到相关文章

最新更新