github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

robap / pillow

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

PHP library to interface with the Zillow API — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

added unit tests 
robap (author)
Sat Oct 31 11:13:55 -0700 2009
commit  6a962fa46f758f2e41095f6ae621a4a0c74a02d4
tree    0e9fbfeacbc4c52cd341552a1331ef692125dcc2
parent  3cc404a861ccba0bac6aa88418fb74fc9d2fabe6
pillow /
name age
history
message
file README.markdown Sat Oct 31 11:13:55 -0700 2009 added unit tests [robap]
directory lib/ Sat Oct 31 11:13:55 -0700 2009 added unit tests [robap]
directory tests/ Sat Oct 31 11:13:55 -0700 2009 added unit tests [robap]
README.markdown

Pillow - Zillow PHP client

This library provides a PHP interface for the Zillow API (see: http://www.zillow.com/howto/api/APIOverview.htm)

Requirements

  • PHP >= 5.2
  • PHP CURL extension

Examples

Get Property - Basic Use

    require '/path/to/pillow/lib/pillow.php';

    $pf = new Pillow_Factory( 'your zws id provided by Zillow' );

    //Third argument specifies regular or Deep Property search
    $property = $factory->findExactProperty($address, $csz, TRUE);

    echo "lat : "   , $property->latitude   , "<br />";
    echo "lon : "   , $property->longitude  , "<br />";
    echo "bath : "  , $property->bathrooms  , "<br />";
    echo "beds : "  , $property->bedrooms   , "<br />";

Get Property - with error handling


    require '/path/to/pillow/lib/pillow.php';

    $pf = new Pillow_Factory( 'your zws id provided by Zillow' );

    try {

        //$search will be an array with 0 or more Pillow_Property objects. Exact
        // matches will be found at $search[0]
        $search = $pf->findDeepProperties( 'some address', 'city state or zip' );

    } catch (Exception $e) {
        
        //Your code to handle exceptions

    }

Get a Zillow Zestimate

    require '/path/to/pillow/lib/pillow.php';

    $pf = new Pillow_Factory( 'your zws id provided by Zillow' );

    try {

        $search = $pf->findDeepProperties( 'some address', 'city state or zip' );

        if( count($search) > 0 )
        {
            echo "zestimate value: ", $search[0]->zestimate->amount;
        }

    } catch (Exception $e) {

        //Your code to handle exceptions

    }

    

Get a Zillow Chart url

    require '/path/to/pillow/lib/pillow.php';

    $pf = new Pillow_Factory( 'your zws id provided by Zillow' );

    try {
        $search = $pf->findDeepProperties( 'some address', 'city state or zip' );
    } catch (Exception $e) {
        //Your code to handle exceptions
    }

    if( count($search) > 0 )
    {
        try {

            $chart = $search[0]->getChart( Pillow_Property::CHART_UNIT_DOLLAR );
            echo "chart url: ", $chart->url, "\n";

        } catch (Exception $e) {

            //Your code to handle exceptions

        }
    }

Get Comparables for a Property

    require '/path/to/pillow/lib/pillow.php';

    $pf = new Pillow_Factory( 'your zws id provided by Zillow' );

    try {

        $search = $pf->findDeepProperties( 'some address', 'city state or zip' );

    } catch (Exception $e) {

        //Your code to handle exceptions

    }

    if( count($search) > 0 )
    {
        try {

            $comparables = $search[0]->getDeepComps(2);

            foreach( $comparables as $comparable )
            {
                echo "comp bath : ", $comparable->bathrooms, "\n";
                echo "comp zestimate : ", $comparable->zestimate->amount, "\n";
            }

        } catch (Pillow_NoCompsException $e) {

            echo "no comps for this address\n";

        } catch (Exception $e) {

            print_r($e);

        }
    }

About Exceptions

The Zillow API can return quite a few different error codes. This php library will throw an appropriate Pillow_* exception for each of these. There are alot (see lib/pillow/Transporter.php). You can choose to handle each of these with try...catch and gain maximum flexibility. But, because they all inherit php's Exception class, you can catch just the Exception. This will make your code simpler.

The exception objects contain useful information for debugging. For example:

$e->getCode(); //Actual status code returned by Zillow service

$e->getMessage(); //Actual message returned by Zillow service

$e->getXmlObject(); //The actual Zillow returned xml as a SimpleXMLElement object

print_r($e); //Dump the whole Exception object

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server