FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » file_get_contents doesn’t access one URL
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: file_get_contents doesn't access one URL [message #179599 is a reply to message #179584] Mon, 12 November 2012 13:11 Go to previous message
Alex vdB is currently offline  Alex vdB
Messages: 3
Registered: November 2012
Karma:
Junior Member
"Charlie" <shymathguy(at)gmail(dot)com> schreef in bericht
news:9d2b587e-ec50-47cf-bec8-97b6b47c60e4(at)k6g2000vbr(dot)googlegroups(dot)com...
> http://www.philadelphia.careerboard.com/job/3167962-MUMPS~2FCache-DBA.aspx
>
> The above is a legitimate URL that I can access by copying it into the
> address field of my browser. However, as an argument to
> file_get_contents I get the error message,
>
> Warning: file_get_contents(http://www.philadelphia.careerboard.com/job/
> 3167962-MUMPS~2FCache-DBA.aspx) [function.file-get-contents]: failed
> to open stream: HTTP request failed! HTTP/1.1 404 Not Found
>
> Any help would be appreciated.

Two possible problems to investigate:

1: '/' is url-encoded ('~2F'). What happens if you don't do that?

2: you may have to send a 'host:' header:
(example copied from the php site and modified)

<?php
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Host: www.philadelphia.careerboard.com\r\n"
)
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file =
file_get_contents('http://www.philadelphia.careerboard.com/job/3167962-MUMPS~2FCache-DBA.aspx',
false, $context);
?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: phpmyadmin export
Next Topic: Get custom header from client
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 06:30:31 GMT 2024

Total time taken to generate the page: 0.05113 seconds