Ring Ring, I pick up the phone and hear "I need to put my real estate properties on
my website, can you do this. I do not want to input them twice, once in the MLS and
again on your our own site." 'Sure,' I say, and hang up the phone. Now what. After
hours of trying to parse through an MLS listing on the internet with unsuccessful
results I stumble upon RETS.
What is this? Well it is a standard that all companies offering MLS listings online
must comply with. It is basically a way to query their data base of property
listings and receive text or xml output to parse through and place into a database.
It is a very easy and fast system with up to date information, if you can figure out
the log on process.
You will first need to contact your local RETS/MLS and get a username and password
that will get you access into the RETS system. You may even need to get your client
who will have to be a real estate agent using the local MLS to call and verify that
you need access. The RETS is usually a free system and is supposed to allow the
sharing of information freely to sell properties faster to a greater audience. Ever
wonder how companies like homefind.com and realtor.org get the listings? One word...
Some RETS systems use a basic authentication, which is like that gray popup box
which pops up on secure directory, which of course is easy to enter into. But on the
whole these systems use a Digest Authorization process. This process of logging and
establishing a session is a lot more secure and more difficult to crack. This
article will discuss the basics of establishing a connection to this type of server.
Hang on for a quick ride into the world of digest and MD5!
Breaking Down The Code
This is the URL of the RETS server.
$url2 = "retslive.mls.com";
Open a connection using fsocket. This is a standard connection script.
$fp2 = fsockopen($url2,80,$errno,$errstr,30);
Create your parts that will be used by MD5.
A1 consists of your "username:mlsid:password" you will have to get these from your
local MLS office.
$A1 = "YOYO:sdmls:GRABB";
A2 consists of the GET of the login page. You may have to get this information from
the RETS/MLS company that you are trying to use. Sometimes they do not place this
information on the internet, you may have to call or email the company.
$A2 = "GET:/IMPV/rets/rets_login.asp";
"Nonce" and 'Opaque' is a sting of characters the RETS server will spit out if you
go to the page without logging in. You will need to get this, either going to it
manually or writing a script. Use Fsocket open to view the headers to get this
information and parse through it.
Now that we have the encryption completed, we login. Following are the headers. Again,
these are pretty standard but they may vary slightly from one RETS server to
Here is the initial GET statement.
The host is just your server ip address that is running this code.
$out2 .= "Host: 188.8.131.526\r\n";
Accept is the type of documents that you want. Below is set to any and all.
$out2 .= "Accept: */*\r\n";
Your user agent is important. You will need to come up with a name for your code and
register it with the RETS/MLS company.
$out2 .="User-Agent: RETSLOGGER/1.0\r\n";
Close the connection.
$out2 .= "Connection: Close\r\n\r\n";
This statement will send the headers we have above.
Now, we will create a loop statement to return all information returned from the RETS
$grabo = fgets($fp2, 128);
Run the code and if you log in successfully you will receive a session-cookie, this
small line of characters and numbers is a huge reward for your perseverance and
countless hours of keystrokes. You will also receive other page links that will give
you access to searches and other information.
This should help you get started in the wonderful world of RETS which is a great
system and can be used in many ways once you get over the hurdle of logging in.