PHP Get XML from Remote URL with Authentication - 403 Error

actiorbteri

New Member
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:\[code\]http://username:p[email protected]\[/code\]However when I try to access it through a php file I get a 403 forbidden:\[code\]$url = "http://username:p[email protected]";$xml = @simplexml_load_file($url);print_r($http_response_header);\[/code\]I have tried using curl and setting the user agent to a browser but this still doesn't echo the data.\[code\]$username = "user";$password = "pass";$process = curl_init("http://user:p[email protected]/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;\[/code\]I also tried using pear's http request 2, which also gives a 403 forbiddenIs the server i'm trying to access refusing all connections via PHP or is there a way around this?Thanks!
 
Back
Top