static void Main(string[] args) { var loginUrl = ""; var username = ""; var password = ""; var userAgent = ""; using (var retsSession = new RetsSession(loginUrl)) { if (!string.IsNullOrEmpty(userAgent)) { retsSession.SetUserAgent(userAgent); } retsSession.SetRetsVersion(RetsVersion.RETS_1_7_2); if (!retsSession.Login(username, password)) { throw new Exception("RETS login failed"); } var loginResponse = retsSession.GetLoginResponse(); // todo: inspect login response } }
static void Main(string[] args) { var loginUrl = "https://some.rets.server.com/rets/login"; var username = ""; var password = ""; var userAgent = ""; using (var retsSession = new RetsSession(loginUrl)) { var uri = new Uri(loginUrl); if (uri.Scheme == Uri.UriSchemeHttps) { // ssl certificate work around - https://groups.google.com/forum/#!searchin/librets/ssl%7Csort:relevance/librets/g62O8pxsAcg/AXzlKi133TUJ retsSession.SetModeFlags(RetsSession.MODE_NO_SSL_VERIFY); } if (!string.IsNullOrEmpty(userAgent)) { retsSession.SetUserAgent(userAgent); } retsSession.SetRetsVersion(RetsVersion.RETS_1_8_0); if (!retsSession.Login(username, password)) { throw new Exception("RETS login failed"); } var loginResponse = retsSession.GetLoginResponse(); // todo: inspect login response } }
static void Main(string[] args) { RetsSession session = null; try { session = new RetsSession( "http://demo.crt.realtors.org:6103/rets/login"); if (args.Length == 1) { session.SetHttpLogName(args[0]); } if (!session.Login("Joe", "Schmoe")) { Console.WriteLine("Invalid login"); Environment.Exit(1); } Console.WriteLine(".Net version: " + System.Environment.Version); LoginResponse login = session.GetLoginResponse(); Console.WriteLine("Member name: " + login.GetMemberName()); CapabilityUrls capabilityUrls = session.GetCapabilityUrls(); Console.WriteLine("Search URL: " + capabilityUrls.GetSearchUrl()); LogoutResponse logout = session.Logout(); Console.WriteLine("Billing info: " + logout.GetBillingInfo()); Console.WriteLine("Logout message: " + logout.GetLogoutMessage()); Console.WriteLine("Connect time: " + logout.GetConnectTime()); } finally { // Be sure to dispose RetsSession when finished, otherwise the // TextWriter Dispose() method may be called prior to RetsSession. if (session != null) { session.Dispose(); } } }
static void Main(string[] args) { RetsSession session = null; try { session = new RetsSession( "http://demo.crt.realtors.org:6103/rets/login"); if (args.Length == 1) session.SetHttpLogName(args[0]); if (!session.Login("Joe", "Schmoe")) { Console.WriteLine("Invalid login"); Environment.Exit(1); } Console.WriteLine(".Net version: " + System.Environment.Version); LoginResponse login = session.GetLoginResponse(); Console.WriteLine("Member name: " + login.GetMemberName()); CapabilityUrls capabilityUrls = session.GetCapabilityUrls(); Console.WriteLine("Search URL: " + capabilityUrls.GetSearchUrl()); LogoutResponse logout = session.Logout(); Console.WriteLine("Billing info: " + logout.GetBillingInfo()); Console.WriteLine("Logout message: " + logout.GetLogoutMessage()); Console.WriteLine("Connect time: " + logout.GetConnectTime()); } finally { // Be sure to dispose RetsSession when finished, otherwise the // TextWriter Dispose() method may be called prior to RetsSession. if (session != null) session.Dispose(); } }
static void Main(string[] args) { /* * Logging may be performed two different ways. The first is legacy * and uses a logging delegate. This can give more control to the user * and remains to support older .NET implementations that already implemented * logging. The second is simply makes use of the existing logging classes * within libRETS and only requires specifying the log file name. */ RetsSession session = null; TextWriter logWriter = null; /* * Legacy method: */ try { session = new RetsSession( "http://demo.crt.realtors.org:6103/rets/login"); if (args.Length == 1) { logWriter = new StreamWriter(args[0]); } else { logWriter = TextWriter.Null; } session.LoggerDelegate = TextWriterLogger.CreateDelegate(logWriter); if (!session.Login("Joe", "Schmoe")) { Console.WriteLine("Invalid login"); Environment.Exit(1); } Console.WriteLine(".Net version: " + System.Environment.Version); LoginResponse login = session.GetLoginResponse(); Console.WriteLine("Member name: " + login.GetMemberName()); CapabilityUrls capabilityUrls = session.GetCapabilityUrls(); Console.WriteLine("Search URL: " + capabilityUrls.GetSearchUrl()); LogoutResponse logout = session.Logout(); Console.WriteLine("Billing info: " + logout.GetBillingInfo()); Console.WriteLine("Logout message: " + logout.GetLogoutMessage()); Console.WriteLine("Connect time: " + logout.GetConnectTime()); } finally { // Be sure to dispose RetsSession when finished, otherwise the // TextWriter Dispose() method may be called prior to RetsSession. if (session != null) { session.Dispose(); } logWriter.Close(); } /* * Preferred method. */ session = null; try { session = new RetsSession( "http://demo.crt.realtors.org:6103/rets/login"); if (args.Length == 1) { session.SetHttpLogName(args[0] + ".1"); } if (!session.Login("Joe", "Schmoe")) { Console.WriteLine("Invalid login"); Environment.Exit(1); } Console.WriteLine(".Net version: " + System.Environment.Version); LoginResponse login = session.GetLoginResponse(); Console.WriteLine("Member name: " + login.GetMemberName()); CapabilityUrls capabilityUrls = session.GetCapabilityUrls(); Console.WriteLine("Search URL: " + capabilityUrls.GetSearchUrl()); LogoutResponse logout = session.Logout(); Console.WriteLine("Billing info: " + logout.GetBillingInfo()); Console.WriteLine("Logout message: " + logout.GetLogoutMessage()); Console.WriteLine("Connect time: " + logout.GetConnectTime()); } finally { // Be sure to dispose RetsSession when finished, otherwise the // TextWriter Dispose() method may be called prior to RetsSession. if (session != null) { session.Dispose(); } } }