Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code for updating MFL my draft list #353

Open
tanho63 opened this issue Apr 14, 2022 · 1 comment
Open

code for updating MFL my draft list #353

tanho63 opened this issue Apr 14, 2022 · 1 comment
Labels
feature 🌟 a feature request or enhancement

Comments

@tanho63
Copy link
Member

tanho63 commented Apr 14, 2022

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
Copy link
Member Author

tanho63 commented Apr 27, 2022

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'))

@tanho63 tanho63 added the feature 🌟 a feature request or enhancement label Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🌟 a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant