C# - Non-Interactive (bot) login

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arienai
    Junior Member
    • Jun 2013
    • 1

    #1

    C# - Non-Interactive (bot) login

    Have finally create my certificate using

    https://api.developer.betfair.com/se...28bot%29+login

    However there's no C# examples on this page or included in the GIT sample login code.

    Any one have any C# examples of how to login using the bot access?

    Thanks
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #2
    Code:
    public string Login(string username, string password)
    {
      string ssoid = String.Empty;
      string[] info;
    
      try
      {
        string uri = string.Format("https://identitysso.betfair.com/api/login?username={0}&password={1}&login=true&redirectMethod=POST&product=home.betfair.int&url=https://www.betfair.com/", username, password);
    
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(uri);
        myRequest.Method = "POST";
        myRequest.Timeout = 5000;
        WebResponse thePage = myRequest.GetResponse();
        info = thePage.Headers.GetValues("Set-Cookie");
        int i = 0;
        while (ssoid == String.Empty && i < info.Length)
        {
          if (info[i].Contains("ssoid=")) ssoid = ExtractSSOID(info[i]);
          ++i;
        }
      }
      catch (System.Exception e)
      {
        Console.WriteLine("\nException Caught!");
        Console.WriteLine("Message :{0} ", e.Message);
      }
    
      SessionID = ssoid;
      return ssoid;
    }

    Comment

    • robne2000
      Junior Member
      • May 2013
      • 19

      #3
      Just trying to move to non interactive logon, and was wondering what this line in the doucmentation means? I'm assuming I just set the password and username to strings containing them - or am I missing something?

      Please note: The username and password values should be encoded when making the login request.

      Comment

      • AlgoTrader
        Junior Member
        • Mar 2012
        • 243

        #4
        HTTP POST data is always encoded when sent to server.
        If your password contains special symbols, they are escaped

        Code:
        escape('One + Two = Three')
        "One%20+%20Two%20%3D%20Three"
        For example space becomes %20 and '=' becomes %3D
        Betfair Bots Made Easy

        Comment

        • robne2000
          Junior Member
          • May 2013
          • 19

          #5
          Thanks - that's quite obvious when someone explains it!

          Comment

          • nokiii
            Junior Member
            • Apr 2014
            • 2

            #6
            Hi!

            Why is it that your example doesn't include the certificate?
            Isn't that mandatory for the Non-Interactive (bot) login ?

            Thanks in advance.

            Comment

            Working...
            X