« Back to Knowledge Base
Delay when using PHP DomDocument to load vMix API
When using PHP to load the vMix API XML, the native DomDocument.loadXML command will take a long time to connect to the vMix web server:
$dom = new DomDocument();
$dom->load("http://127.0.0.1:8088/API/");
$dom->load("http://127.0.0.1:8088/API/");
Instead of loading the web site directly, use CURL first:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8088/api/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8088/api/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$dom = new DomDocument();
$dom->loadXML($output);
$dom->loadXML($output);
Last Updated: Tuesday, December 15, 2015 10:18:25 AM