I have some php in WordPress using HTTP_Request2 that I'm struggling to convert to use wp_remote_post.
This code currently works:
$xmlCustomerDataByAuthorLicenseID = '
<GetCustomerDataByAuthor>
<AuthorID>ABC123</AuthorID>
</GetCustomerDataByAuthor>';
$requestDataLicense = new HTTP_Request2(
$urlCustomerDataByAuthor,HTTP_Request2::METHOD_POST);
$requestDataLicense->addPostParameter(
'xml', $xmlCustomerDataByAuthorLicenseID);
$requestDataLicenseResponse = $requestDataLicense->send();
$xmlDataParsed = simplexml_load_string(
$requestDataLicenseResponse->getBody());
foreach ($xmlDataParsed->{"Customer"} as $individualCustomer)
{
$customerEmail = strtolower(trim($individualCustomer->Email));
}
This is my failed attempt:
$requestDataLicenseResponse = wp_remote_post(
$urlCustomerDataByAuthor,
array(
'headers' => array(
'Content-Type' => 'text/xml'
),
'body' => array('xml' => $xmlCustomerDataByAuthorLicenseID),
'sslverify' => false
)
);
$xmlDataParsed = simplexml_load_string($requestDataLicenseResponse ->getBody());
foreach ($xmlDataParsed->{"Customer"} as $individualCustomer)
{
$customerEmail = strtolower(trim($individualCustomer->Email));
}
The expect input for the service is
<GetCustomerDataByAuthor xmlns="">
<AuthorID>value</AuthorID>
</GetCustomerDataByAuthor>