Reputation: 105
I'm trying to print the xml source content of a page from its url using this :
echo file_get_contents("http://eur-lex.europa.eu/legal-content/FR/TXT/XML/?uri=CELEX:32012R0823
However, an error message appears:
Warning: file_get_contents(http://eur-lex.europa.eu/legal-content/FR/TXT/XML/?uri=CELEX:32012R0823)
What is wrong please ? What is the best way to get the source XML ?
Upvotes: 2
Views: 93
Reputation: 105
My problem is solved ! My company's proxy was the responsible. To overpass it, I installed CNTLM (local proxy : command line tools). With this, you must update cntlm.ini with the company's proxy's information and run this command :
cntlm -I -f -c {path of cntlm.ini}
Then, the php script :
$aContext = array(
'http' => array(
'proxy' => "localhost:{port(in cntlm.ini find 'listen', in my case it is 3128)}",
'request_fulluri' => True,
'userid'=>"{username}",
'password'=>"{password}"
)
);
$context = stream_context_create($aContext);
$content = file_get_contents({your target url string}, 0, $context);
echo $content;
I hope that it will help !
Upvotes: 0
Reputation: 11
it could be blocked by header if you declared in source page try ob_start() function in the top of your page.
Upvotes: 1