VBNet Sample (Yes really)

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #256
    The login URL (endpoint) in my program has some sort of registration code included in it where the WebBrowser object is created and it may be that that code related to my program as registered with Betfair. The log in screen appears to be a Betfair screen. I'm wondering if I could delete the ssid file to trick my progam into going through the LoginForm code.

    Comment

    • geoffw123
      Senior Member
      • Mar 2014
      • 250

      #257
      Hi

      Hmmm, what error does it give you now when you try and logon ? Use a sniffer tool to grab the comms strings see what goes up/down the wire.

      I am not saying its wrong, but I dont really understand why that url line is so complicated and long.

      My C# version is much simpler

      string myStr = string.Format("https://identitysso.betfair.com/api/login?username={0}&password={1}", userName, password);

      I just setup a few params like POST etc, and the headers and then a filled in myStr goes out on the wire.
      That is working fine for me

      Are you sure your Appkey is OK and works ?

      Regards

      Comment

      • tippete
        Junior Member
        • Mar 2016
        • 42

        #258
        Thanks all for perservering with me.

        I am still getting "Login Problem The request was aborted:Could not create SSL/TLS secure channel.

        I tried the simpler Login but gives same result.

        Dim uri As String = String.Format("https://identitysso.betfair.com/api/login?username={0}&password={1}", username, password)
        ' Dim uri As String = String.Format("https://identitysso.betfair.com/api/login?username={0}&password={1}&login=true&redirec tMethod=POST&product=home.betfair.int&url=https://www.betfair.com/", username, password)

        The App key is tried and tested on another program.

        Comment

        • tippete
          Junior Member
          • Mar 2016
          • 42

          #259
          I forgot to mention i notice the Wait cursor appears when i hover the mouse anywhere in the groupBox

          Comment

          • geoffw123
            Senior Member
            • Mar 2014
            • 250

            #260
            Hi

            Which version of dot net are you using ?

            Comment

            • WTPooh
              Member
              • May 2012
              • 88

              #261
              Code:
              Function Login(userName As String, password As String) As LoginResponse
              Dim request As HttpWebRequest = WebRequest.Create(New Uri("https://identitysso.betfair.com/api/login"))
              request.Headers.Add("X-Application", appKey)
              request.Accept = "application/json"
              request.ContentType = "application/x-www-form-urlencoded"
              request.Method = "POST"
              Dim postData = $"username={userName}&password={password}"
              Dim bytes = Encoding.UTF8.GetBytes(postData)
              request.ContentLength = bytes.Length
              Using stream = request.GetRequestStream()
              stream.Write(bytes, 0, bytes.Length)
              End Using
              Using response = request.GetResponse(), stream = response.GetResponseStream(),
              reader = New StreamReader(stream, Encoding.UTF8)
              Dim s = reader.ReadToEnd()
              Return JsonConvert.DeserializeObject(Of LoginResponse)(s)
              End Using
              End Function

              Comment

              • tippete
                Junior Member
                • Mar 2016
                • 42

                #262
                The version is 4.8 according to registry.
                i'm running windows 10 and visual studio 2013

                Thanks for the try with th code WTP but this throws up more problems

                Comment

                • jabe
                  Senior Member
                  • Dec 2014
                  • 705

                  #263
                  My debug effort to help came to nothing today. My session still hadn't expired about 16 hours of inactivity later.

                  Comment

                  • tippete
                    Junior Member
                    • Mar 2016
                    • 42

                    #264
                    Didn't want to cause you any problems Jabe

                    Comment

                    • WTPooh
                      Member
                      • May 2012
                      • 88

                      #265
                      Originally posted by tippete View Post
                      The version is 4.8 according to registry.
                      i'm running windows 10 and visual studio 2013

                      Thanks for the try with th code WTP but this throws up more problems
                      My code is working. What is the problem?

                      Comment

                      • tippete
                        Junior Member
                        • Mar 2016
                        • 42

                        #266
                        the problem i get with your code WTH
                        Attached Files

                        Comment

                        • WTPooh
                          Member
                          • May 2012
                          • 88

                          #267
                          1. Add a class LoginResponse to your project:
                          Code:
                          Public Class LoginResponse
                          
                          <JsonProperty(PropertyName:="token")>
                          Public token As String
                          
                          <JsonProperty(PropertyName:="product")>
                          Public product As String
                          
                          <JsonProperty(PropertyName:="status")>
                          Public status As LoginStatus
                          
                          <JsonProperty(PropertyName:="error")>
                          Public [error] As String
                          
                          End Class
                          LoginStatus
                          Code:
                          <JsonConverter(GetType(StringEnumConverter))>
                          Public Enum LoginStatus
                          SUCCESS
                          LIMITED_ACCESS
                          LOGIN_RESTRICTED
                          FAIL
                          End Enum
                          2. Replace appKey with the reference to your application key.
                          3. Replace
                          Dim postData = $"username={userName}&password={password}"
                          with
                          Dim postData = String.Format("username={0}&password={1}", userName, password)
                          Last edited by WTPooh; 14-11-2020, 04:26 PM.

                          Comment

                          • jabe
                            Senior Member
                            • Dec 2014
                            • 705

                            #268
                            Originally posted by tippete View Post
                            Didn't want to cause you any problems Jabe
                            I come on here to help people along, so don't worry about that. If I can, that is.
                            Last edited by jabe; 14-11-2020, 05:10 PM.

                            Comment

                            • tippete
                              Junior Member
                              • Mar 2016
                              • 42

                              #269
                              Hi guys, Ok so the program appears to login without error. Only problem is it doesn't load anything else ie. todays races , just pops up with "Todays Races".
                              Since i've made so many changes think i will delete and start again. "i will be back".

                              Comment

                              • tippete
                                Junior Member
                                • Mar 2016
                                • 42

                                #270
                                Hi guys not been around a while. Managed to sort out the login problems after upgrading to visual studio 2019. Worked out a selection plan and obtaining selection Id and market Id . Can anyone point me to a program for a simple back bet using basic.net

                                Comment

                                Working...
                                X