Skip to content

Examples in C plus plus

Mark Lesswing edited this page Mar 7, 2017 · 1 revision

#include "librets.h" #include

using namespace librets; using std::cout; using std::cerr; using std::endl;

int main(int argc, char * argv[]) { try { RetsSessionPtr session( new RetsSession("http://demo.crt.realtors.org:6103/rets/login")); session->Login("JoeSchmoe", "JoesPassword");

    SearchRequestPtr searchRequest(
        new SearchRequest("Property", "ResidentialProperty", 
                          "(ListPrice=300000-)"));
    
    SearchResultSetPtr results = session->Search(searchRequest);
    while (results->HasNext())
    {
        cout << "ListingID: " << results->GetString("ListingID") << endl;
        cout << "ListPrice: " << results->GetString("ListPrice") << endl;
        cout << "     Beds: " << results->GetString("Beds") << endl;
        cout << "     City: " << results->GetString("City") << endl;
        cout << endl;
    }
    
    session->Logout();
}
catch (RetsException & e)
{
    e.PrintFullReport(cerr);
}

}