BillyT Posted October 21, 2008 Share Posted October 21, 2008 Hi all using a script that I got from the seo with php book http://www.seoegghead.com/blog/professional-seo-with-php-book It attempts to populate a database with the data provided by the friendly people at iplists.com However, it is failing due to a curl issue and I am unsure what the problem is. curl is enabled on the server (mediatemple gridserver) basic code $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, 'http://www.iplists.com/nw/google.txt'); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); $result = curl_exec($ch); echo $result; which outputs HTTP/1.1 403 Forbidden Date: Tue, 21 Oct 2008 04:05:44 GMT Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Content-Length: 517 Connection: close Content-Type: text/html; charset=iso-8859-1 Forbidden You don't have permission to access /nw/google.txt on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. Is it an issue with my code, server, the way connections are handled by the external server, or something else? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/129353-curl-issue/ Share on other sites More sharing options...
sKunKbad Posted October 21, 2008 Share Posted October 21, 2008 The external server is telling you that you don't have permission to view/open/access that file. I spoke too soon. I'll see what I can do and get back to you. Quote Link to comment https://forums.phpfreaks.com/topic/129353-curl-issue/#findComment-670616 Share on other sites More sharing options...
sKunKbad Posted October 21, 2008 Share Posted October 21, 2008 So, I figured out that you just have to set the CURLOPT_USERAGENT. This works for me: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17'); curl_setopt($ch, CURLOPT_URL, 'http://iplists.com/nw/google.txt'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); $result = curl_exec($ch); echo "<pre>$result</pre>"; ?> In this case I used Firefox, but you could probably use anything you want. Quote Link to comment https://forums.phpfreaks.com/topic/129353-curl-issue/#findComment-670638 Share on other sites More sharing options...
BillyT Posted October 21, 2008 Author Share Posted October 21, 2008 You are a legend Thanks mate - much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/129353-curl-issue/#findComment-670657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.