Jump to content

[SOLVED] file_get_contents() can't access a URL that a browser can


bibliovermis

Recommended Posts

The problem URL is [ http://www.neobux.com/rel/bl/?o=D4B44A9F3179942FCED0E440FF71F64F828DC2990AD18F9E ].

 

It can be accessed via a browser, however using file_get_contents returns the following error after timing out: "failed to open stream: HTTP request failed!"

 

I've tried using cURL to mimic a browser, with no success. The URL loads perfectly fine on a machine that has never visited the neobux site, so it isn't a tracking issue of some type.

 

Thank you for any insight into this perplexing issue.

Link to comment
Share on other sites

Likely url wrappers are disabled within your php configuration.

 

My apologies for not clarifying that file_get_contents works for any other URL.

 

I did try explicitly turning on the allow_url_fopen flag via htaccess & using the full fopen routine, with no change in result.

Link to comment
Share on other sites

They appear to be using a fairly restrictive proxy server. (header shows Server:proxyshield-proxy4)

 

I did manage to get the page contents using curl mimicking Firefox.

 

$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Connection: keep-alive';
$header[] = 'Keep-Alive: 300';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Pragma: ';
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.neobux.com/rel/bl/?o=D4B44A9F3179942FCED0E440FF71F64F828DC2990AD18F9E');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;

Link to comment
Share on other sites

  • 2 years later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.