ffverse / ffscrapr

R API Client for Fantasy Football League Platforms
https://ffscrapr.ffverse.com
Other
76 stars 21 forks source link

code for updating MFL my draft list #353

Open tanho63 opened 2 years ago

tanho63 commented 2 years ago
library(ffscrapr)
library(httr)

conn <- mfl_connect(season = 2022, league_id = 54040,user_name = "{username}",password = "{password}")

add_mydraftlist <- function(conn, franchise_id, player_ids){

  httr::POST(
    "https://www61.myfantasyleague.com/2022/my_draft_list",
    body = list(
      LEAGUE_ID = conn$league_id,
      FRANCHISE_ID = franchise_id,
      ACTION = "import",
      DRAFT_LIST = paste(player_ids, collapse = "\r\n"),
      import = "Import+My+Draft+List"
    ),
    conn$auth_cookie
  )

}

add_mydraftlist(conn, franchise_id = "0001",player_ids = c("0805","11222")
tanho63 commented 2 years ago

predraft picks here, same idea

update_predraft_picks <- function(conn,franchise_id,round,picks){

  data = list(
    `LEAGUE_ID` = conn$league_id,
    `FRANCHISE_ID` = franchise_id,
    `ROUND` = round,
    # `MAX_ROUNDS` = '32',
    # `ALL_DRAFT_PICKS` = '27,28,29,30,31,32,',
    # `sel_pid` = '',
    `PICKS` = picks %>% paste(collapse = ",")
    # `continue` = 'Save These Picks And Continue'
  )

  res <- httr::POST(
    url = 'https://www61.myfantasyleague.com/2022/new_predraft', 
    conn$auth_cookie,
    body = data, 
    encode = 'form')
  cli::cli_alert(httr::status_code(res))
  return(invisible(res))

}

update_predraft_picks(conn,"0001","29",c('12476','15285','12505','15425','12152'))