Hi,
I am trying to read the content of url.
when manually i put url in browser

link : http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions
it opens.

but using code

$homepage = file_get_contents('http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions');
echo $homepage;

Warning: file_get_contents(http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable in C:\xampp\htdocs\test.php on line 2

What is problem ?
How to solve this?

Member Avatar

nileshgr

Your server admin must have turned off fopen'ing of URLs.

Use cURL (www.php.net/curl)

extension=php_curl.dll
it's on (i.e. already remove ;)

CAn you please tell me what to do?

Member Avatar

nileshgr

Post php.ini as attachment.

Hi,
I posted php.ini as attachment.

To attach PHP.ini file it gives me error so i rename it to PHP-ini.php
and then upload.

Plz help me to solve this..

Hi,
I am trying to read the content of url.
when manually i put url in browser

link : http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions
it opens.

but using code

$homepage = file_get_contents('http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions');
echo $homepage;

Warning: file_get_contents(http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable in C:\xampp\htdocs\test.php on line 2

What is problem ?
How to solve this?

There is nothing wrong with your code. It is just the response from the server:

HTTP/1.1 503 Service Unavailable

That means that the server is unavailable. Usually this is a temporary error.

NB: if the allow_url_fopen setting is preventing http requests you'd get a: "http wrapper disabled etc.." error

hi,

any other way to read the html of url??

Member Avatar

nileshgr

damn it. What happened to me that day when I was answering this thread lol.

Aamit, Your code is correct, but the server's down. You take any method to read HTML of URL be it file_get_contents or cURL, it can't help if the server is down.

Thanks Man I have the same problem now I know what was wrong thanks a alot man.

Just pass user agent like this in your CURL param

$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";

// set user agent
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

Please can you helpme rewrite this code to bypass the the User-Agent http header in this code. I have been getting the error "failed to open stream: HTTP request failed" when I run the code. Please find part of the script below:

function runapp($dir,$latdeg,$latmin,$latsec,$longdeg,$longmin,$longsec)
{
global $_english;

    $query= ($_english ? 'http://esnig.org/cgi-bin/ntv2_geo2_e.cgi' : 'http://esnig.org/cgi-bin/ntv2_geo2_f.cgi').
        '?' . PAR_DIR     .'=' . $dir .
        '&' . PAR_LATDEG  .'=' . $latdeg .
        '&' . PAR_LATMIN  .'=' . $latmin .
        '&' . PAR_LATSEC  .'=' . $latsec .
        '&' . PAR_LONGDEG .'=' . $longdeg .
        '&' . PAR_LONGMIN .'=' . $longmin .
        '&' . PAR_LONGSEC .'=' . $longsec;


    $response=file($query); 

    foreach ($response as $value)
    {
        echo $value;
    }
}
?>