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? 
Google.com  
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

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek