API-NG for dummies

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lmlac
    Junior Member
    • Feb 2014
    • 27

    #16
    Hi tkw141. Haven't received your PM. Probably because you sent it to username Imlac, which is what I used to be, but I changed the structure of my account and couldn't use that forumname again so I used lmlac which is v similar except it starts with an l not I.

    Comment

    • lmlac
      Junior Member
      • Feb 2014
      • 27

      #17
      Worked out a way to login through VBA. But it's a massive bodge. Already had the cURL command line working, so just called that from VBA to get the session token. Takes 200 lines of code to pipe it through instead of probably 6 lines of XML/HTML gubbins, but 200 lines that work are better than 6 that don't!

      Comment

      • lmlac
        Junior Member
        • Feb 2014
        • 27

        #18
        I'm using the listevents call to get today's matches. The string returned is {"jsonrpc":"2.0","result":[{"event":{"id":"27151641","name":"TSW Pegasus FC (Res) v Sun Hei SC (Res)","countryCode":"HK","timezone":"GMT","openDa te":"2014-02-19T12:30:00.000Z"},"marketCount":14},{"event":{"id ":"27151646","name":"Humble Lions v Boys Town FC... etc etc

        Now I want to get a list of ids for each event. So I use the parse function for the result collection in class module jsonlib, which returns an object. I can use the for each ... construct to return each event/marketcount pair as an object, but I can't work out how to get to the id field that is somewhere in the event object. I tried to use the tostring method to get a clue, and from that this code should work but it doesn't:

        For Each eventItem In jason_obj
        this_eventx = eventItem("event")
        this_id = this_eventx("id")
        Next

        Anybody any clues? I can solve anagrams if you want to give it in that form

        Comment

        • lmlac
          Junior Member
          • Feb 2014
          • 27

          #19
          OK Imlac as no-one else can help I'll give you the answer ... again. Objects need to be set and references should use item:

          For Each eventItem In jason_obj
          set this_eventx = eventItem.item("event")
          this_id = this_eventx.item("id")
          Next

          Comment

          • catfloppo
            Junior Member
            • Nov 2012
            • 5

            #20
            Good news about the sample spreadsheet. Imlac, you are not alone, I have a vba app that I want to convert as effortlessly as I can and I have a friend in the same position.

            Comment

            • lmlac
              Junior Member
              • Feb 2014
              • 27

              #21
              The way I did it was to keep the API6 objects and methods eg oserviceproxy, obets etc and just replace the soap call with the json methods. And use the json data returned to build obet objects etc.

              Comment

              • catfloppo
                Junior Member
                • Nov 2012
                • 5

                #22
                Yes, that will be my approach too but I have yet to even look at how the methods correlate, is it straightforward?

                Comment

                • lmlac
                  Junior Member
                  • Feb 2014
                  • 27

                  #23
                  It's pretty straightforward. JSON is easier to work with than using SOAP. Most of the methods have the same functionality as the API6 equivalents. Logging in is a bit of a faff to get working - the excel example assumes you already have a session token. And the market menupath isn't fully replicated - the parentID concept isn't there as far as I can see.

                  Comment

                  • catfloppo
                    Junior Member
                    • Nov 2012
                    • 5

                    #24
                    I sent you a/pm, Imlac

                    Comment

                    • lmlac
                      Junior Member
                      • Feb 2014
                      • 27

                      #25

                      catfloppo :
                      I sent you a/pm, Imlac


                      See post 16

                      Comment

                      • catfloppo
                        Junior Member
                        • Nov 2012
                        • 5

                        #26
                        Well, I clicked on your user to send it so it should have worked?
                        In case not I was simply wondering if you would consider selling your converted library.

                        Comment

                        • lmlac
                          Junior Member
                          • Feb 2014
                          • 27

                          #27
                          Although I started with the same methods as you, I have tweaked them over the years, and you couldn't pay me enough to do the work to remove those tweaks. Like you I have used Rentacoder in the past. That would definitely be a cheaper option!

                          Comment

                          • catfloppo
                            Junior Member
                            • Nov 2012
                            • 5

                            #28
                            OK, fair enough, I have too. I have considered rentacoder but I'd like to find someone who has worked with the betfair api before. Maybe I'll get lucky!

                            Comment

                            Working...
                            X