We have a proxy with authentication at work. I am able to get html by using the following code, how can I get data from xml, does “stream_context_create” work with xml, if not what does? Can someone help me write the method below but with fetching xml data? I appreciate any help/input.
[code=php]
$username = ‘jdoe’;
$password = ‘password’;
$opts = array(‘http’=>array(‘proxy’=>’tcp://172.15.15.3:8080’,’request_fulluri’=>true,’header’=>sprintf(“Proxy-Authorization: Basic %srn”,base64_encode(“$username:$password”))));
$context = stream_context_create($opts);
echo file_get_contents(‘http://www.google.com’,false,$context);
[code=php]
$zip = ‘95757’;
$xml = simplexml_load_file(‘http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA–&street=’.$zip);
$city = $xml->Result[0]->City;
$state = $xml->Result[0]->State;
echo ‘<b>City: </b>’.$city.'<br />’;
echo ‘<b>State: </b>’.$state.'<br />’;