phillc73 / abettor

An R package for connecting to the online betting exchange Betfair, via their API-NG product, using JSON-RPC.
Other
51 stars 36 forks source link

Change from using RCurl to httr #11

Closed phillc73 closed 3 years ago

phillc73 commented 8 years ago

The httr provides a much nicer and easier to user interface than RCurl. I'd like to change this package to use httr rather than RCurl.

See backblazer package for example: https://github.com/phillc73/backblazer/blob/master/R/b2AuthorizeAccount.R

phillc73 commented 5 years ago

loginBF() and keepAlive() functions updated to httr. Thanks to input from @willtudorevans @bcaneco on issue #21

freddiec commented 5 years ago

loginBF function works fine using httr package instead of RCurl. Is there any chance of changing the logoutBF function to use httr as well?

phillc73 commented 5 years ago

@freddiec Yes, for sure I can look at converting that function next. I'm traveling for a few days, but will aim to do it next week.

freddiec commented 5 years ago

Brilliant, much appreciated.

Sent from my iPad

On 6 Jun 2019, at 20:18, Phill notifications@github.com wrote:

@freddiec Yes, for sure I can look at converting that function next. I'm traveling for a few days, but will aim to do it next week.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

freddiec commented 5 years ago

Did you find time to take a look at converting the logoutBF() function to use httr instead of RCurl ? Betfair no longer recognises the original version. .Thanks.

thewetdog commented 5 years ago

@freddiec - the following might help you with logging out.

alternativeLogoutBF <- function(suppress = TRUE, sslVerify = TRUE){
  if(suppress){
    logout <- suppressWarnings(
      as.list(
        httr::content(
          httr::POST(
            url = "https://identitysso.betfair.com/api/logout", config = httr::config(ssl_verifypeer = sslVerify),
            httr::add_headers(
              Accept = "application/json",
              `X-Application` = Sys.getenv("product"),
              `X-Authentication` = Sys.getenv("token"),
              `Content-Type` = "application/json"
            )
          )
        )
      )
    )
  } else(
    logout <- as.list(
      httr::content(
        httr::POST(
          url = "https://identitysso.betfair.com/api/logout", config = httr::config(ssl_verifypeer = sslVerify),
          httr::add_headers(
            Accept = "application/json",
            `X-Application` = Sys.getenv("product"),
            `X-Authentication` = Sys.getenv("token"),
            `Content-Type` = "application/json"
          )
        )
      )
    )
  )
  return(paste0(logout$status, ":", logout$error))
}
freddiec commented 5 years ago

Hi wetdog,Worked an absolute treat. Thank you very much for your help, you're a star !Regards,freddiec  -----Original Message----- From: thewetdog notifications@github.com To: phillc73/abettor abettor@noreply.github.com CC: freddiec johnfcrump@aol.com; Mention mention@noreply.github.com Sent: Sun, 21 Jul 2019 13:55 Subject: Re: [phillc73/abettor] Change from using RCurl to httr (#11)

@freddiec - the following might help you with logging out.alternativeLogoutBF <- function(suppress = TRUE, sslVerify = TRUE){ if(suppress){ logout <- suppressWarnings( as.list( httr::content( httr::POST( url = "https://identitysso.betfair.com/api/logout", config = httr::config(ssl_verifypeer = sslVerify), httr::add_headers( Accept = "application/json", X-Application = Sys.getenv("product"), X-Authentication = Sys.getenv("token"), Content-Type = "application/json" ) ) ) ) ) } else( logout <- as.list( httr::content( httr::POST( url = "https://identitysso.betfair.com/api/logout", config = httr::config(ssl_verifypeer = sslVerify), httr::add_headers( Accept = "application/json", X-Application = Sys.getenv("product"), X-Authentication = Sys.getenv("token"), Content-Type = "application/json" ) ) ) ) ) return(paste0(logout$status, ":", logout$error)) } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

phillc73 commented 3 years ago

Done, thanks to @Soccerama