Creating a mashup
Aug 24
Fun and troublesome!
Mashup in progress
Issues:
- Installing PEAR on shared GoDaddy server, thanks to Abby and Win’s Blog
- Getting Zillow data (easy!)
- Altering GoogleMapAPI.class.php (from phpinsider.com)
- Moving from PEAR DB to MDB2 (what I used for reference because DB is deprecated in the latest version of PEAR)
- changed function getCache:
function getCache($address) {
if(!isset($this->dsn)) return false;
$_ret = array();
// PEAR MDB2
require_once("MDB2.php");
$_db =& MDB2::connect($this->dsn);
if (PEAR::isError($_db)) {
die($_db->getMessage() . ', ' . $_db->getDebugInfo());
}
if (PEAR::isError($_db)) {
die($_db->getMessage(). ', ' . $_db->getDebugInfo());
}
$_res =& $_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = '$address'");
if (PEAR::isError($_res)) {
die($_res->getMessage(). ', ' . $_res->getDebugInfo());
}
if($_row = $_res->fetchRow()) {
$_ret['lon'] = $_row[0];
$_ret['lat'] = $_row[1];
}
$_db->free();
return !empty($_ret) ? $_ret : false;
} - changed function putCache:
function putCache($address, $lon, $lat) {
if(!isset($this->dsn) || (strlen($address) == 0 || strlen($lon) == 0 || strlen($lat) == 0))
return false;
// PEAR MDB2
require_once("MDB2.php");
$_db =& MDB2::connect($this->dsn);
if (PEAR::isError($_db)) {
die($_db->getMessage() . ', ' . $_db->getDebugInfo());
}
$_res =& $_db->query("insert into ".$this->_db_cache_table." values ('$address', $lon, $lat)");
if (PEAR::isError($_res)) {
die($_res->getMessage());
}
$_db->free();
return true;
} - GoogleMap API (easy once I figured it liked addresses better than the lat/long Zillow was returning…)
Stay tuned for more developments…
To do:
- fix line-height of superscripted registration mark
- integrate multiple listings
- integrate search
- integrate 2 other (maybe 3?) API’s to be named later