Home arrow PHP arrow Page 2 - RETS: Small Name, Big Possibilities

How it Works - PHP

What is RETS? At first glance it sounds like something you may want to avoid, but for the professional Realtor and their web developer itís like gold. It helps Realtors update property information on the MLS server, saving time and keeping listings current. It can all be done through PHP and a good database.

  1. RETS: Small Name, Big Possibilities
  2. How it Works
  3. The Basic Login in Detail
  4. The Login Script
  5. Authentication
  6. Benefits of RETS
  7. Final Thoughts
By: Ron Goff
Rating: starstarstarstarstar / 16
October 25, 2004

print this article



You first have to develop a client. A client is a program that connects to the RETS server and extracts certain information and displays or places what it pulled into a database. There are many pre-made clients available, some even written in PHP, but I found that they do not work for every RETS server straight out of the box and require a bit of updating to work with a specific RETS server, which is not an easy task when the code does not have sufficient comments or documentation. That is why I suggest building your own; usually one of the best ways to learn anything is doing it on your own. The Wright Brothers would have never built their first plane if they were waiting to update someone else's plane. Let's look at what the client program will have to do.

Most of the RETS servers implement Digest Authentication. This is much more secure than your usual Basic Authentication, which makes it a little more complicated to program. Digest uses MD5 to encrypt usernames and passwords and other variables so that information is not sent over the Internet. We will get into the login process a little bit later in this article.

Once you log in, you will receive a session id which you will need to save so you can log back in to request information. RETS servers have many options to pull information out; you can search by price, amenities, location, school district, Realtor office and basically anything else that is a field in the RETS server.

This is how a common session might look.

The Common Session 

Program Step 1
Logs in and retrieves the session_id and then logs out

Program Step 2
Logs in using the session_id and requests a list of property id numbers and then logs out

Program Step 3
Logs in using the session_id and requests detailed information on specific id number and then logs out

Program Step 4
repeat step 3 for all property ids in the database

Program Step 5
session completed.

Once you have a successful login and request information, the RETS server will send a page back with all the information you requested. The information will be in the same order that you sent the request, so if you asked for bedrooms, bathrooms and pool, it would come back in that same order. The content will be in a format that looks like the below sample.

Sample Data 

HTTP/1.1 200 OK (This lets us know everything was fine retrieving from this page)
Server: Microsoft-IIS/5.0 (Type of server the RETS server is)
Date: Thu, 08 Jul 2004 23:05:33 GMT (The date and time of the transaction)
X-Powered-By: ASP.NET (What type of programming language is used on the RETS server)
Cache-Control: private
RETS-Version: RETS/1.0 (The standards version the RETS server complies with)
Content-Type: text/plain (Format of the information below)
Cache-control: private
<RETS ReplyCode="0" ReplyText="Operation Successful." > (Everything is ok)
<COUNT Records="4" /> (Number of records were found)
<DELIMITER value="09" />
<COLUMNS> ListingPrice MLNumber Status </COLUMNS> (How the data is formatted)
<DATA> 198500 13603 A </DATA> (The data)
<DATA> 93000 13880 A </DATA>
<DATA> 318000 14029 P </DATA>
<DATA> 275000 14056 P </DATA>

You can see from the above sample data that it is in an XML format which makes it really easy to parse through and place into a database.  This is similar to RSS news feeds, which makes it very easy to place news into a database.  You may have tried to parse MLS data off of a website before  - it is nearly impossible, this is why this is so great; you get the data in a very easy to parse format and can worry about bigger things like how to tell your co-worker that a water cooled computer does not mean pouring water on the processor every few hours.

The system we built in our office checks the RETS server every hour for any updates and adds and removes properties based on the information that the server spits back. We have automated it through a cron job and we can just sit back and let the computer do all the work, day and night.

>>> More PHP Articles          >>> More By Ron Goff

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: