VBNet Sample (Yes really)

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts

  • tippete
    replied
    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

    Leave a comment:


  • tippete
    replied
    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".

    Leave a comment:


  • jabe
    replied
    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.

    Leave a comment:


  • WTPooh
    replied
    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.

    Leave a comment:


  • tippete
    replied
    the problem i get with your code WTH
    Attached Files

    Leave a comment:


  • WTPooh
    replied
    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?

    Leave a comment:


  • tippete
    replied
    Didn't want to cause you any problems Jabe

    Leave a comment:


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

    Leave a comment:


  • tippete
    replied
    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

    Leave a comment:


  • WTPooh
    replied
    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

    Leave a comment:


  • geoffw123
    replied
    Hi

    Which version of dot net are you using ?

    Leave a comment:


  • tippete
    replied
    I forgot to mention i notice the Wait cursor appears when i hover the mouse anywhere in the groupBox

    Leave a comment:


  • tippete
    replied
    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.

    Leave a comment:


  • geoffw123
    replied
    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

    Leave a comment:


  • jabe
    replied
    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.

    Leave a comment:

Working...
X