<?php @(include_once 'login.php'); ?> <pre> <?php $rets = new PHRETS(); $connect = $rets->Connect($login, $un, $pw); if ($connect) { $sixmonths = date('Y-m-d\\TH:i:s', time() - 15778800); // get listings updated within last 6 months /* Search RETS server */ $search = $rets->SearchQuery('Property', 4, '((112=' . $sixmonths . '+),(178=ACT))', array('Format' => 'COMPACT-DECODED', 'Select' => 'sysid,49,112,175,9,2302,2304', 'Count' => 1, 'Limit' => 20)); /* If search returned results */ if ($rets->TotalRecordsFound() > 0) { while ($data = $rets->FetchRow($search)) { print_r($data); } } else { echo '0 Records Found'; } $rets->FreeResult($search); $rets->Disconnect(); } else { $error = $rets->Error(); print_r($error); } ?> </pre>
<?php @(include_once 'login.php'); ?> <pre> <?php $rets = new PHRETS(); $connect = $rets->Connect($login, $un, $pw); if ($connect) { /* Get table layout */ $fields = $rets->GetMetadataTable("Property", 4); /* Take the system name / human name and place in an array */ $table = array(); foreach ($fields as $field) { $table[$field['SystemName']] = $field['LongName']; } /* Display output */ print_r($table); $rets->Disconnect(); } else { $error = $rets->Error(); print_r($error); } ?> </pre>
<?php error_reporting(1); require_once 'lib/phrets.php'; /////////////////////////// LOGIN INFO ///////////////////////////// $login = '******'; // Will not work in GODaddy Server or some servers so be carefull before choosing Hosting Provider for RETS API. $un = 'username'; // Provide your RETS username $pw = 'password'; // Provide your RETS password //////////////////////////////////////////////////////////////////// $rets = new PHRETS(); $connect = $rets->Connect($login, $un, $pw); if ($connect) { echo "Connection Successfull <br/>"; echo "Location : Markham <br/>"; echo "Type: ResidentialProperty/CondoProperty <br/>"; // Give the property Type to pull data. ResidentialProperty/CondoProperty echo "Query: Municipality_code:'09.03'<br/>"; // Sample City Markham, Canada Data pulled using Muncipality Code echo "Date : " . date('Y-m-d', strtotime('-7 days')); // Setting date to 1 week earlier to pull RETS property listings. $queryStringData = "Municipality_code:'09.03',(Timestamp_sql=" . date('Y-m-d', strtotime('-7 days')) . "+))"; $search = $rets->SearchQuery('Property', "ResidentialProperty", $queryStringData, array('Limit' => 1000)); // Pulling RETS data from API with max count 1000 and last updated 1 week earlier /* If search returned results */ echo "Total Records Found " . $rets->TotalRecordsFound() . " <br/>"; while ($data = $rets->FetchRow($search)) { echo json_encode($data) . "<br/>"; // Printing JSON data of each property. You can either save to DB here.
<?php @(include_once 'login.php'); ?> <pre> <?php /* Initialize Object */ $rets = new PHRETS(); /* Connect */ $connect = $rets->Connect($login, $un, $pw); /* Query Server */ if ($connect) { $types = $rets->GetMetadataTypes(); print_r($types); $rets->Disconnect(); } else { $error = $rets->Error(); print_r($error); } ?> </pre>
<?php @(include_once 'login.php'); ?> <pre> <?php $rets = new PHRETS(); $connect = $rets->Connect($login, $un, $pw); if ($connect) { $sysid = '156456'; $n = 1; $dir = 'photos/' . $sysid; if (!is_dir($dir)) { mkdir($dir); } // Remember: this can only make one directory at a time $photos = $rets->GetObject('Property', 'Photo', $sysid); foreach ($photos as $photo) { file_put_contents($dir . '/' . $n . '.jpg', $photo['Data']); $n++; } $rets->FreeResult($photos); $rets->Disconnect(); } else { $error = $rets->Error(); print_r($error); } ?> </pre>