I have a script that uses SimpleXMLElement to access an API from an external provider. The same script is used on many websites to provide real-time content.
It works well almost all the time, however when the external provider has an occasional problem, it prevents my page from loading properly, and causes server overload because multiple httpd processes never finish.
The code in question is
Code: Select all
$pFile = new SimpleXMLElement('http://api.XXX.com/a/XXX-api/xml-v2/ws-'.$number.'/q-'.$terms.'?pshid=XXX&ssty=1&cflg=r', null, true);502 Bad Gateway
nginx
I have tried entering the following snippet into the script but it didn't work:
Code: Select all
libxml_use_internal_errors(true);
if (!$pFile) {
echo "Failed loading XML\n";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
}
Thanks
Mike