/** * 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; }
/** * Creates a config object and uses it to create a PHRETS session * * @param string $type type of call - meta or normal (default is normal) * @return \PHRETS\Session * @throws \PHRETS\Exceptions\MissingConfiguration if the username/password isn't set in the settings */ public function start($type = null) { $login = $this->login; $config = new \PHRETS\Configuration(); $config->setLoginUrl($this->url)->setUsername($login)->setPassword($this->password)->setRetsVersion('1.7'); $this->retsfeed = new \PHRETS\Session($config); $connect = $this->retsfeed->Login(); return $this->retsfeed; }
public function setUp() { $client = new GuzzleHttp\Client(); $watcher = new Gsaulmon\GuzzleRecorder\GuzzleRecorder(__DIR__ . '/Fixtures/Http'); $watcher->includeCookies(false); $client->getEmitter()->attach($watcher); \PHRETS\Http\Client::set($client); $config = new \PHRETS\Configuration(); $config->setLoginUrl('http://retsgw.flexmls.com/rets2_1/Login')->setUsername(getenv('PHRETS_TESTING_USERNAME'))->setPassword(getenv('PHRETS_TESTING_PASSWORD'))->setRetsVersion('1.7.2'); $this->session = new PHRETS\Session($config); $this->session->Login(); }
public function login() { // Prepare config $config = new \PHRETS\Configuration(); $config->setLoginUrl($this->url); $config->setUsername($this->login); $config->setPassword($this->password); // Create the connection $this->connection = new \PHRETS\Session($config); // Try to login $result = $this->connection->Login(); return (bool) $result; }
echo "Start date starting at midnight: " . $newdatestring . "\n"; // Get config properties $ini = parse_ini_file("ezrets.ini", true); // use http://retsmd.com to help determine the SystemName of the DateTime field which // designates when a record was last modified $rets_modtimestamp_field = "LIST_87"; // use http://retsmd.com to help determine the names of the classes you want to pull. // these might be something like RE_1, RES, RESI, 1, etc. $property_classes = array("A"); // 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]; }
/** @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); }
/** @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(); }