コード例 #1
2
/**
 * 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);
    }
}
コード例 #2
0
 /** @test **/
 public function it_uses_http_post_method_when_desired()
 {
     $config = new \PHRETS\Configuration();
     // this endpoint doesn't actually exist, but the response is mocked, so...
     $config->setLoginUrl('http://retsgw.flexmls.com/rets2_1/Login')->setUsername(getenv('PHRETS_TESTING_USERNAME'))->setPassword(getenv('PHRETS_TESTING_PASSWORD'))->setRetsVersion('1.7.2')->setOption('use_post_method', true);
     $session = new \PHRETS\Session($config);
     $session->Login();
     $system = $session->GetSystemMetadata();
     $this->assertSame('demomls', $system->getSystemId());
     $results = $session->Search('Property', 'A', '*', ['Limit' => 1, 'Select' => 'LIST_1']);
     $this->assertCount(1, $results);
 }
コード例 #3
0
 public static function properties($object, $objectType, $query)
 {
     $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 {
         $results = $rets->Search($object, $objectType, $query, ['QueryType' => 'DMQL2', 'Count' => 1, 'Format' => 'COMPACT-DECODED', 'Limit' => env('RETS_PULL'), 'StandardNames' => 0]);
     } catch (Exception $e) {
         Bugsnag::notifyException($e);
     } catch (PHRETS\Exceptions\CapabilityUnavailable $e) {
         Bugsnag::notifyException($e);
     }
     $rets->Disconnect();
     return $results;
 }
コード例 #4
0
ファイル: mls-3-get-properties.php プロジェクト: ezinaz/rets
}
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();
    $resource = "Property";
    $query = "({$rets_modtimestamp_field}={$newdatestring}+)";
    while ($maxrows) {
        // run RETS search
        echo "   + Query: {$query}  Limit: {$limit}  Offset: {$offset}<br>\n";
        $results = $rets->Search($resource, $class, $query, ['QueryType' => 'DMQL2', 'Count' => 1, 'Format' => 'COMPACT-DECODED', 'Limit' => $limit, 'Offset' => $offset, 'StandardNames' => 0]);
        $properties = array();
        foreach ($results as $record) {
            $property = array();
            foreach ($fields as $field) {
                $property[$field] = $record[$field];
            }
            $properties[] = $property;
            fputcsv($fh, $property);
        }
        // update offset
        $offset = $offset + count($results);
        echo 'offset is now ' . $offset;
        $maxrows = $results->isMaxRowsReached();
    }
    var_dump($properties);