Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To use file_get_content over/through a proxy that doesn't require authentication, something like this should do :</p> <p><em>(I'm not able to test this one : my proxy requires an authentication)</em></p> <pre><code>$aContext = array( 'http' =&gt; array( 'proxy' =&gt; 'tcp://192.168.0.2:3128', 'request_fulluri' =&gt; true, ), ); $cxContext = stream_context_create($aContext); $sFile = file_get_contents("http://www.google.com", False, $cxContext); echo $sFile; </code></pre> <p>Of course, replacing the IP and port of my proxy by those which are OK for yours ;-)</p> <p>If you're getting that kind of error :</p> <pre><code>Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 407 Proxy Authentication Required </code></pre> <p>It means your proxy requires an authentication.</p> <p>If the proxy requires an authentication, you'll have to add a couple of lines, like this :</p> <pre><code>$auth = base64_encode('LOGIN:PASSWORD'); $aContext = array( 'http' =&gt; array( 'proxy' =&gt; 'tcp://192.168.0.2:3128', 'request_fulluri' =&gt; true, 'header' =&gt; "Proxy-Authorization: Basic $auth", ), ); $cxContext = stream_context_create($aContext); $sFile = file_get_contents("http://www.google.com", False, $cxContext); echo $sFile; </code></pre> <p>Same thing about IP and port, and, this time, also LOGIN and PASSWORD ;-)</p> <p>Now, you are passing an <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.34" rel="nofollow noreferrer">Proxy-Authorization</a> header to the proxy, containing your login and password.</p> <p>And... The page should be displayed ;-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload