static void Main(string[] args)
        {
            if (args.Count() != 3)
            {
                Console.WriteLine("This sample takes 3 arguments: <username> <appkey> <pathtocertfile>");
                Console.WriteLine("You will then be prompted for the password for this account.");
            }
            else
            {
                var username = args.First();
                var appKey = args.ElementAt(1);
                var certFilename = args.ElementAt(2);
                Console.WriteLine("Please enter your password:"******"");

                var client = new AuthClient(appKey);
                try
                {
                    var resp = client.doLogin(username, password, certFilename);
                    Console.WriteLine("Response Type: " + resp.LoginStatus);
                    if (resp.LoginStatus == "SUCCESS")
                    {
                        Console.WriteLine("Obtained the session token: " + resp.SessionToken);
                    }
                }
                catch (CryptographicException e)
                {
                    Console.WriteLine("Could not load the certificate: " + e.Message);
                }
                catch (HttpRequestException e)
                {
                    Console.WriteLine("The Betfair Login endpoint returned an HTTP Error: " + e.Message);
                }
                catch (WebException e)
                {
                    Console.WriteLine("An error occurred whilst attempting to make the request: " + e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("An Error Occurred: " + e.Message);
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if (args.Count() != 3)
            {
                Console.WriteLine("This sample takes 3 arguments: <username> <appkey> <pathtocertfile>");
                Console.WriteLine("You will then be prompted for the password for this account.");
            }
            else
            {
                var username     = args.First();
                var appKey       = args.ElementAt(1);
                var certFilename = args.ElementAt(2);
                Console.WriteLine("Please enter your password:"******"");

                var client = new AuthClient(appKey);
                try
                {
                    var resp = client.doLogin(username, password, certFilename);
                    Console.WriteLine("Response Type: " + resp.LoginStatus);
                    if (resp.LoginStatus == "SUCCESS")
                    {
                        Console.WriteLine("Obtained the session token: " + resp.SessionToken);
                    }
                }
                catch (CryptographicException e)
                {
                    Console.WriteLine("Could not load the certificate: " + e.Message);
                }
                catch (HttpRequestException e)
                {
                    Console.WriteLine("The Betfair Login endpoint returned an HTTP Error: " + e.Message);
                }
                catch (WebException e)
                {
                    Console.WriteLine("An error occurred whilst attempting to make the request: " + e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("An Error Occurred: " + e.Message);
                }
            }
        }