Webhook XML 始终为空

Webhook XML always empty

我正在使用循环 webhooks 来更新联系人,但是 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;
}