I have a URL which gives an xml output. It requires a username and password which I can access through a browser using the format:
http://username:password@url.com
However when I try to access it through a php file I get a 403 forbidden:
$url = "http://username:password@url.com";
$xml = @simplexml_load_file($url);
print_r($http_response_header);
I have tried using curl and setting the user agent to a browser but this still doesn't echo the data.
$username = "user";
$password = "pass";
$process = curl_init("http://user:pass@url.com/feed?feed_id=1");
//curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);
echo $return;
I also tried using pear's http request 2, which also gives a 403 forbidden
Is the server i'm trying to access refusing all connections via PHP or is there a way around this? Thanks!