2

I was trying to use the Zillow API. Actually, It is working on my local and returns all the data I need but when I tried to publish it in our hosting, the API returns "Request blocked, crawler detected."

This is the sample code that works in my local but not in our server.

echo @file_get_content("example.xml");

Thanks!

aldesabido
  • 1,268
  • 2
  • 17
  • 38
  • 1
    maybe you should try curl request instead of file_get_content function. like this; http://stackoverflow.com/questions/2440729/php-curl-how-can-i-emulate-a-get-request-exactly-like-a-web-browser – Mustafa Toker Feb 24 '15 at 06:40
  • Thank you for your response but, I already used curl and the result is just the same. – aldesabido Feb 24 '15 at 06:42

2 Answers2

5

Im pretty sure Zillow grants an API key to restrict anyone from accessing their data, and to monitor how much data is being served. This is standard practice for just about any public API.

EDIT: Removed header suggestion. Zillow wants you to pass in the API key as a query string parameter. The URL would look something like this.

http://www.zillow.com/webservice/GetDemographics.htm?zws-id <ZWSID>&state=WA&city=Seattle&neighborhood=Ballard

In php you could try cURL or file_get_contents: A cURL example:

$apiKey = qadsf78asdfjkasdjf-yourAPIKey
$url = 'http://www.zillow.com/webservice/GetDemographics.htm?zws-id=' . $apiKey . 
       '&state=TX&city=Austin';

$ch = curl_init($url);

    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec( $ch );
print_r($response);

curl_close( $ch ); 

You can pass in a lot of options in cURL, check this page for further reading. http://php.net/manual/en/book.curl.php

cpk
  • 809
  • 1
  • 6
  • 20
  • Here is the main page of their API : http://www.zillow.com/howto/api/APIOverview.htm – Veve Feb 24 '15 at 10:45
  • Thanks for the answers. Though it works on my local machine, it blocks us on accessing the API when I try to access it in our server. – aldesabido Feb 24 '15 at 23:43
  • At that point i would be sure to set `ini_set('display_errors', 1);` to get more information. You may have a more recent version of PHP on your local machine. If not try `sudo apt-get install curl`, then restart apache. You should type `php -v` on your local and remote as SSH to make sure the versions of PHP are the same. – cpk Feb 24 '15 at 23:50
  • The version of PHP in my local is 5.3.3 and 5.4.37 in our server, which is higher, Is it possible that the latest version is the problem? – aldesabido Feb 25 '15 at 02:12
  • I would read the logs from both your local environment and the server. You could be missing certain packages on your server. Also, you need to make sure the URL is set correctly in your Zillow API account. Change it from `localhost` to your server IP / URL. – cpk Feb 25 '15 at 02:35
  • 1
    you mean the error_log? I just read it but there's no error occuring. And yes, the URL has been set correctly. The local is working perfectly even though the URL is my server's IP, And by the way, I've already updated my local PHP to 5.4 and it's also working. So, the PHP version is not the issue here. really, Thank you for your all response @cpk – aldesabido Feb 25 '15 at 03:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71638/discussion-between-aldesabido-and-cpk). – aldesabido Feb 25 '15 at 03:38
  • Glad I can help. PHP is always a pain the ass with consistency. One of the reasons I switched to using a Vagrant environment to serve from an exact, or damn close replica of the web server. – cpk Feb 25 '15 at 05:12
  • Running out of ideas here. It is flagging your server on their end for SOME reason. Maybe contact them. Could you have hit the maximum 1k requests/ day from your servers IP? – cpk Feb 25 '15 at 05:32
  • Actually, this is our first time using this API so the maximum request is not the issue here. Unfortunately, their customer support is not responding at all :( – aldesabido Feb 25 '15 at 07:35
0

Zillow seems to return that crawler message if you're using a vpn.

jmdeamer
  • 337
  • 2
  • 16