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

Authentication - 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



The lines below will be the header we create and send over for authentication. These are the usual minimum requirements but again may be slightly different from MLS server to MLS server. You may want to take some time before trying the authentication process to locate and check the requirements of your local office; they are usually posted online.

$out2 = "GET /IMPV/rets/rets_login.asprn";

The page we use for authentication. Notice that it differs slightly from our $A2 variable.

$out2 .= "Authorization: Digest username="$username ", realm="$MLS_county ",
nonce="$auth_nonce ", opaque="$auth_opaque", uri="/IMPV/rets/rets_login.asp", response="$resp" rn";                

This is the actual digest string that brings everything together for authentication. Some of the variables we created above are placed here and our MD5ed variable $resp is in the response area at the end.

You will notice that there is a variable called opaque. This variable will appear when you get the nonce variable from the header and looks similar to the nonce. You can pull it the exact same way that you pull the nonce. Again my specific MLS server does not change this variable, but others might.

$out2 .= "Host:";

The server that you will post this code to and run the program from.

$out2 .= "Accept: */*rn";

The type of response you will accept. Some MLS server may require you to specify the type which may be text or XML. The above is set to anything and everything.

$out2 .="User-Agent: MY_RETS_CLIENT/1.0rn";

This is the name of your client; this will need to be registered with the MLS office. This is to prevent any program from trying to gain access without properly registering with the MLS office. You may be familiar with this variable which usually holds information about your browser like "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us)". We are basically spoofing the header; if it's not set, it would probably say "PHP 4.2.3" or whatever version your PHP is on the server.

$out2 .="RETS-Request-ID: 571rn";

This is used by your program to keep track of requests. Every request could have a unique number assigned to it for logging or record keeping. This is usually an optional variable.

$out2 .= "Connection: Closernrn";

Finally close the connection.

fputs($fp, $out2); 

Now we connect to our fsocket connection and send over the header we just made. The header is a GET statement and not a POST, information that you may not need but is good to know how things are being sent.

while (!feof($fp)) { 
        $grabo = fgets($fp, 128); 

      preg_match("/RETS-Session-ID(..........)/", $grabo, $set_cookie);
     if($set_cookie[0] != ''){
      $set_cookiea = $set_cookie[0];


This bit of code retrieves the server response once we send our authentication. If we are successful, it will try to find a variable called RETS-Session-ID. If we get this variable, then it means that we have successfully logged into the server and can process requests for property using that session id.

>>> 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: