1

I have a function that pulls info from whitepages.com and it worked perfectly. I moved the code to a new server and now I am having a problem with curl and white pages only. I also access other sites using curl like zillow.com and it works fine.

the code im using is :

<?php
$ch3 = curl_init(); 
    curl_setopt($ch3, CURLOPT_CONNECTTIMEOUT, 15);
    curl_setopt($ch3, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch3, CURLOPT_URL, "http://www.whitepages.com/name/john-smith/md"); 
    curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1); 
    $output2 = curl_exec($ch3); 
curl_close($ch3);

?>
<?=$output2;?>

I dont know if it is a problem with cURL or PHP or the server itself. PHP Version 5.3.17. older sever:PHP Version 5.2.4. it seems to work on every other server we have. I dont know if there is an option in php or cURL I need to turn on. thanks.

EDIT: here is the phpinfo in the curl section

cURL support      enabled
cURL Information    7.24.0
Age 3
Features
AsynchDNS   No
Debug   No
GSS-Negotiate   No
IDN Yes
IPv6    Yes
Largefile   Yes
NTLM    Yes
SPNEGO  No
SSL     Yes
SSPI    No
krb4    No
libz    Yes
CharConv    No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3,   pop3s, rtsp, smtp, smtps, telnet, tftp
Host    x86_64-unknown-linux-gnu
SSL Version OpenSSL/1.0.0
ZLib Version    1.2.3

It is a dedicated server from gatorhost. I think it is linux-RedHat-9.8.2. and all it says is "couldn't connect to host"

We have confirmed the code works fine. (We ran a test from both hosts). There is something on the host itself that is blocking access to whitepages. cURL is enabled, we attempted using an alternate port (ie... 8080). Also, tried establishing the specific browser headers and user agent (from the following post) Can servers block curl requests?

Nothing we have established seems to make any bit of difference.... We are also thinking it is a firewall issue, but we checked locally here and there is not a problem. I can only think that it is blocked on the server. We have a "reseller" dedicated server, access to php.ini, etc...

briandonor
  • 63
  • 3
  • 11
  • This needs basic debugging first. An example how to get more verbose information with curl you can find here: http://stackoverflow.com/questions/9550319/bad-request-connecting-to-sites-via-curl-on-host-and-system/9571305#9571305 - Basic debugging means, you need to share more information about your kind of error, just having a "I get an error" or "it does not work" is too little for good programming help. As you can imagine there are trillions of servers, you need to learn how to deal with these problems because you will get problems in the future as well. – hakre Sep 26 '12 at 07:53
  • i had posted it in a comment under someone else. it is a dedicated server from gatorhost. I think it is linux-RedHat-9.8.2. and all it says is "couldn't connect to host" – briandonor Sep 26 '12 at 13:12
  • Your teammate should add the additional details to your question and you should contact whitepages.com and ask for support in sending HTTP requests to their site even nothing on your end is blocking the connection. – hakre Sep 26 '12 at 13:15

4 Answers4

0

This looks fine to me.

I also ran your code and it seemed to work just fine.

Sam Phippen
  • 146
  • 7
0

Turn on error reporting error_reporting(E_ALL);. Maybe the new server doesn't have cURL enabled.

CappY
  • 1,510
  • 1
  • 17
  • 32
0

It could be returning error and you are not seeing it because of your server configuration. Try adding this to the top of the script

error_reporting(E_ALL);
ini_set("display_error", "On");
Baba
  • 94,024
  • 28
  • 166
  • 217
0

This is the OP's teammate. We have confirmed the code works fine. (We ran a test from both hosts). There is something on the host itself that is blocking access to whitepages. cURL is enabled, we attempted using an alternate port (ie... 8080). Also, tried establishing the specific browser headers and user agent (from the following post) Can servers block curl requests?

Nothing we have established seems to make any bit of difference.... We are also thinking it is a firewall issue, but we checked locally here and there is not a problem. I can only think that it is blocked on the server. We have a "reseller" dedicated server, access to php.ini, etc...

Community
  • 1
  • 1