I have a URL that prompts for a username/password to get its data. The data is in XML format. At first I tried to retrieve the data like this:
$url = "http://username:password@[ip-address]:8086/connectioncounts?flat";
$xml = simplexml_load_file($url);
print_r($xml);
After searching for an answer I've come up with this code:
$url = "http://[ip-address]:8086/connectioncounts?flat";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
I'm not getting any data returned on either of these attempts. Could someone tell me what I'm doing wrong?