The Peoplevox re-authentication response script
Introduction
About the re-authentication response script
<?php
/**
* Invalid PVX auth response comes with HTTP 200 code and this body:
* <?xml version="1.0" encoding="utf-8"?>
* <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
* <soap:Body>
* <AuthenticateResponse xmlns="http://www.peoplevox.net/">
* <AuthenticateResult>
* <ResponseId>-1</ResponseId>
* <TotalCount>0</TotalCount>
* <Detail>System : Security:Invalid Username or Password</Detail>
* <Statuses />
* <ImportingQueueId>0</ImportingQueueId>
* <SalesOrdersToDespatchIds />
* <ErrorCode>72e420d4-6892-4333-83b5-e7214fbf561b</ErrorCode>
* </AuthenticateResult>
* </AuthenticateResponse>
* </soap:Body>
* </soap:Envelope>
*
* If this content is present in the response, we'll need to force reauthentication by returning the correct script response code. See https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape/using-connector-shape-response-scripts#response-code for more information
*/
function handle($data)
{
if (str_contains($data['payload'], 'Invalid Username or Password')) {
// request had invalid auth, need to force reauth
$data['response_code'] = 4; // reauth response code
$data['message'] = 'Request to PVX was unauthenticated, forcing reauthentication.';
} else {
// nothing needed, response will be handled as normal
}
return $data;
}Implementing the response script

What if I don't use this script?
PreviousUsing the Peoplevox setData script in process flowsNextPeoplevox XML to JSON conversion script
Last updated
Was this helpful?