PHP
  Home arrow PHP arrow Page 5 - RETS: Small Name, Big Possibilities
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

RETS: Small Name, Big Possibilities
By: Ron Goff
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 15
    2004-10-25


    Table of Contents:
  • RETS: Small Name, Big Possibilities
  • How it Works
  • The Basic Login in Detail
  • The Login Script
  • Authentication
  • Benefits of RETS
  • Final Thoughts

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    RETS: Small Name, Big Possibilities - Authentication
    ( Page 5 of 7 )

    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.

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

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

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

    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.

    <code>
    $out2 .= "Host: 63.171.248.226rn";
    </code>

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

    <code>
    $out2 .= "Accept: */*rn";
    </code>

    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.

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

    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.

    <code>
    $out2 .="RETS-Request-ID: 571rn";
    </code>

    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.


    <code>
    $out2 .= "Connection: Closernrn";
    </code>
       

    Finally close the connection.

    <code>
    fputs($fp, $out2); 
    </code>

    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.

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

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

    fclose($fp); 
    }
    </code>

    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
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT