Welcome Guest, Not a member yet? Register   Sign In
Accessing Zillow API with CodeIgniter
#1

[eluser]taewoo[/eluser]
I wrote a wrapper for this class if anyone's interested in doing real estate web app.

/system/application/plugin/zillow_pi.php :

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Zillow
{
    var $api_key;
    
    
    function Zillow()
    {
        $this->CI =& get_instance();
        $this->api_key = $this->CI->config->item('Zillow_API_key');
    }
    
    function GetZestimate($zpid)
    {
        return $this->_url_parser("GetZestimate", array("zpid"=>$zpid));
    }

    function GetSearchResults($address, $citystatezip)
    {
        return $this->_url_parser("GetSearchResults", array("address"=>$address,
                                                            "citystatezip"=>$citystatezip));
    }
    
    function GetChart($zpid, $unit_type, $width=NULL, $height=NULL, $chartDuration=NULL)
    {
        return $this->_url_parser("GetChart", array("zpid"=>$zpid,
                                                    "unit_type"=>$unit_type,
                                                    "width"=>$width,
                                                    "height" =>$height,
                                                    "chartDuration"=>$chartDuration));
    }
    
    function GetComps($zpid, $count)
    {
        return $this->_url_parser("GetComps", array("zpid"  =>$zpid,
                                                    "count" =>$count));
    }
    
    
    function _url_parser($function_name, $arguments)
    {
        $arguments["zws-id"] = $this->api_key;
        $url = "http://www.zillow.com/webservice/".$function_name.".htm?".http_build_query($arguments);
        //echo $url;
        $handle = @fopen($url, "r");
        $xml_string = array();
        if ($handle) {
            while (!feof($handle)) {
                $buffer = fgets($handle, 4096);
                $xml_string[] = trim($buffer);
            }
            fclose($handle);
        }
        
        
        return new SimpleXMLElement(implode("\n", $xml_string));
    }
}

?>
In system/application/config/config.php

Code:
$config['Zillow_API_key'] = 'YOUR_ZILLOW_API_KEY';

To use it in your controller:

Code:
$this->load->plugin('zillow');
$zillow = new Zillow();
...
#2

[eluser]UF Sebastian[/eluser]
Has anybody tried using this plugin other than me? This plugin does not work. It was a good effort by the publisher but this plugin does not work and there are no comments to help the implementation.
#3

[eluser]taewoo[/eluser]
It works fine for me...
Look at my widget page
#4

[eluser]UF Sebastian[/eluser]
Are you running PHP4 or 5?
#5

[eluser]taewoo[/eluser]
5
#6

[eluser]chuckleberry13[/eluser]
worked great for me!!! Thanks a ton for posting this. Was just what I needed.
#7

[eluser]taewoo[/eluser]
Glad it helped u chuck




Theme © iAndrew 2016 - Forum software by © MyBB