Jump to content

Archived

This topic is now archived and is closed to further replies.

johnnyk

fopen, file, readfile all 403d

Recommended Posts

Warning: fopen(http://en.wikipedia.org/wiki/PHP): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in wikipedia.html on line 16

Why is it 403ing? Is there anyway to analyze wikipedia page with php?

Share this post


Link to post
Share on other sites
I heard fsockopen would stop the 403, but I tried it out and it won't make a connection at all. At least I don't think it makes a connection cause the script aint working.

Share this post


Link to post
Share on other sites
This will get you started.

You will need to make sure that the cURL extension is enabled.

[code]$page = "http://en.wikipedia.org/wiki/PHP";

function processURL($url){
       $url=str_replace('&','&',$url);
       $ch=curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
       $xml = curl_exec ($ch);
       curl_close ($ch);
       echo $xml;
}

echo processURL($page);[/code]

Read the manual pages on cURL as well:

[a href=\"http://www.php.net/curl\" target=\"_blank\"]http://www.php.net/curl[/a]

Share this post


Link to post
Share on other sites

×

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.