/    Sign up×
Community /Pin to ProfileBookmark

stream_context_create with xml through proxy

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]

[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 />’;
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @phpnstuff spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...