Robert Leverington <lcarsdata@...> writes:
Some user agents are blocked, I had this problem when I tried to create a PHP script to access MediaWiki. You need to somehow change your user-agent setting.
On 05/05/07, David DeGroote <David@...> wrote:
I'm building a web site that contains small portions of Wikipedia articles. I have been using php curl to obtain the articles, caching them, and checking once a week for updates I've started getting the following message:
The Wikimedia Foundation servers are currently experiencing technical difficulties. [.... snip ...] Request: GET http://en.wikipedia.org/wiki/Cinco_De_Mayo, from 64.202.165.131 Error: ERR_ACCESS_DENIED, errno [No Error] at Fri, 04 May 2007 23:16:48 GMT
Because of the ERR_ACCESS_DENIED above, I'm concerned I've been doing this the wrong way and have gotten blocked. I would very much appreciate it if someone could tell me if this is the case.
Thanks, I've tried various user agents and none is working. The thing is this code worked fine up until a few weeks ago, so I suspect it's somthing else. Any other ideas?
Here's the function I'm using for testing:
function getURL($domain, $url) { $domain = "en.wikipedia.org"; // Force - debugging $url = "/wiki/Cinco_De_Mayo";
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $domain. $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, "http://DaysUntil.com/"); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6" // curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); $result = curl_exec($ch); curl_close ($ch); return $result; }
Thanks again, David DeGroote