/**
 * getProperties()
 *
 */
function getProperties($limit = 250)
{
    $config = new \PHRETS\Configuration();
    $config->setLoginUrl('http://rets.realtracs.com:6103/rets/login')->setUsername('360Zen')->setPassword('919558')->setRetsVersion('1.7.2')->setUserAgent('360Zen/1.0');
    $rets = new \PHRETS\Session($config);
    //    $rets->setLogger($log);
    $connect = $rets->Login();
    $residential = $rets->Search('Property', 'RES', '(OfficeCoListCode=PLKT01,PLKT02)', ['Limit' => $limit]);
    $land = $rets->Search('Property', 'LLF', '(OfficeCoListCode=PLKT01,PLKT02)', ['Limit' => $limit]);
    $condos = $rets->Search('Property', 'CND', '(OfficeCoListCode=PLKT01,PLKT02)', ['Limit' => $limit]);
    //build array of results
    $allListings = [];
    foreach ($residential as $l) {
        $allListings[] = $l;
    }
    foreach ($land as $l) {
        $allListings[] = $l;
    }
    foreach ($condos as $l) {
        $allListings[] = $l;
    }
    $args = array('post_type' => 'listing');
    $all_posted_listings = get_posts($args);
    $post_to_mls_array = [];
    foreach ($all_posted_listings as $post) {
        $id = $post->ID;
        $mls_value = get_post_meta('_pilkerton_listing_mls')[0];
        $post_to_mls_array[$id] = $mls_value;
    }
    //iterate over results
    foreach ($allListings as $listing) {
        //check if post with MLS number exists
        //if it does NOT exist, create new post
        //New Listings- agent, address, price, square footage, bed/bath, subdivision, MLS area
        $post_agent_name = $listing['AgentListFullName'];
        //        $agent2 = $listing['AgentCoListFullName'];
        $mls_number = $listing['MlsNum'];
        $post_content = $listing['Remarks'];
        $area = $listing['AreaID'];
        $image_url = $listing['PrimaryPictureURL'];
        $post_title = $listing['StreetNumber'] . ' ' . $listing['StreetName'] . ' ' . $listing['StreetLetter'] . ' ' . $listing['StreetDirection'];
        $address = $post_title;
        $city = $listing['City'];
        $zip = $listing['ZipCode'];
        $sqft = number_format($listing['SqFtTotal']);
        $beds = $listing['TotalBedrooms'];
        $half_baths = $listing['TotalHalfBaths'] * 0.5;
        $full_baths = $listing['TotalFullBaths'];
        $baths = (string) ($half_baths + $full_baths);
        setlocale(LC_MONETARY, 'en_US.UTF-8');
        $price = money_format('%.2n', $listing['ListPrice']);
        //Solds- agent, address, price
        //if user exists with same name as primary agent, get user ID, otherwise, it's null
        // @TODO: get_user_by('slug') doesn't work. need to refactor to search by full name.
        //        $user_id = get_user_by('slug',$post_agent_name) ?: null;
        //        $user = $user_id ? 'Yes' : 'No';
        //check if post with MLS number exists
        $post_id = array_search($mls_number, $post_to_mls_array);
        $exists = $post_id ? 'Yes' : 'No';
        $details = ['MLS Number' => $mls_number, 'Agent' => $post_agent_name, 'Description' => $post_content, 'Area' => $area, 'Title' => $post_title, 'Address' => $address, 'City' => $city, 'Zip' => $zip, 'Square Feet' => $sqft, 'Bedrooms' => $beds, 'Bathrooms' => $baths, 'Price' => $price, 'Post exists?' => $exists];
        var_dump($details);
    }
}
 public static function photos($objectType, $objectSelect, $MLSNumber)
 {
     $config = new \PHRETS\Configuration();
     $config->setLoginUrl(env('RETS_LOGIN_URL'))->setUsername(env('RETS_USERNAME'))->setPassword(env('RETS_PASSWORD'))->setRetsVersion(env('RETS_VERSION'));
     $rets = new \PHRETS\Session($config);
     $connect = $rets->Login();
     try {
         $photos = $rets->GetObject($objectType, $objectSelect, $MLSNumber);
     } catch (Exception $e) {
         Bugsnag::notifyException($e);
     } catch (PHRETS\Exceptions\CapabilityUnavailable $e) {
         Bugsnag::notifyException($e);
     }
     $rets->Disconnect();
     return $photos;
 }
Exemplo n.º 3
0
// DateTime which is used to determine how far back to retrieve records.
// using a really old date so we can get everything
//$previous_start_time = "2016-02-12T00:00:00";
//$previous_start_time = "2016-01-01T00:00:00";
$config = new \PHRETS\Configuration();
$rets_config = $ini['rets_config'];
$config->setLoginUrl($rets_config['loginurl']);
$config->setUsername($rets_config['username']);
$config->setPassword($rets_config['password']);
$config->setRetsVersion($rets_config['rets-version']);
$config->setHttpAuthenticationMethod('digest');
$config->setOption('disable_follow_location', false);
$config->setOption('use_post_method', true);
$rets = new \PHRETS\Session($config);
$rets->setLogger($log);
$connect = $rets->Login();
$file = fopen('output/Property-A-fields.csv', 'r');
$header = fgetcsv($file);
$fields = array();
while (($result = fgetcsv($file)) !== false) {
    $fields[] = $result[0];
}
foreach ($property_classes as $class) {
    echo "+ Property:{$class}<br>\n";
    $file_name = strtolower("data/property_{$class}_data.csv");
    $fh = fopen($file_name, "w+");
    fputcsv($fh, $fields);
    $maxrows = true;
    //$offset = 1;
    $limit = 500;
    $fields_order = array();
 /** @test **/
 public function it_recovers_from_bad_lookuptype_tag()
 {
     $config = new \PHRETS\Configuration();
     $config->setLoginUrl('http://retsgwlookup.flexmls.com/rets2_1/Login')->setUsername(getenv('PHRETS_TESTING_USERNAME'))->setPassword(getenv('PHRETS_TESTING_PASSWORD'))->setRetsVersion('1.5');
     $session = new \PHRETS\Session($config);
     $session->Login();
     $values = $this->session->GetLookupValues('Property', '20000426151013376279000000');
     $this->assertCount(6, $values);
 }
Exemplo n.º 5
0
 /** @test **/
 public function it_doesnt_allow_requests_to_unsupported_capabilities()
 {
     $config = new \PHRETS\Configuration();
     // fake, mocked endpoint
     $config->setLoginUrl('http://retsgwlimited.flexmls.com/rets2_1/Login')->setUsername(getenv('PHRETS_TESTING_USERNAME'))->setPassword(getenv('PHRETS_TESTING_PASSWORD'))->setRetsVersion('1.7.2');
     $session = new \PHRETS\Session($config);
     $session->Login();
     $this->setExpectedException('\\PHRETS\\Exceptions\\CapabilityUnavailable');
     // make a request for metadata to a server that doesn't support metadata
     $session->GetSystemMetadata();
 }