Beispiel #1
1
<?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>
$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.
    }
    $rets->FreeResult($search);
    $rets->Disconnect();
} else {
    $error = $rets->Error();
    print_r($error);
}