aldesabido aldesabido - 1 month ago 8
PHP Question

Zillow - Request blocked, crawler detected

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!

cpk cpk
Answer

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

Comments