I am trying to generate tweet according to user input in R. It is the first time that I am using shiny.
In order to use the tweet button I have used the link I got from the web intent tweet generator.
However, I want to update the tweet link according to what the user selects in the select button. So far I was only able to get the tweet button which when clicked would only give me the tweet I generated through web intent tweet generator.
What I have done so far is:
url = "https://twitter.com/intent/tweet?text=name"
ui <- dashboardPage(
dashboardSidebar(
sidebarMenu(
menuItem("test", tabName = 'test'))
tabItem(tabName = 'test',
h2('test2'),
fluidRow(
box(width = 12,
column(width= 3,
selectInput("name", "Select name",
choices = sort(unique(df$name), decreasing = F)),
br(),
fluidRow(style='margin: 2px;',
actionButton("twitter_share_button",
label = "Tweet",
icon = icon("twitter"),
onclick = sprintf("window.open('%s')",url)
)))))
server(input, output, session) {
dat <- reactive({
df
})
}
shinyApp(ui = ui, server = server)
However, I want to update the tweet according to what user selects in the select field.
There is a similar question asked here and I implemented the suggested solution but somehow it is not working. The link to the question: Update URL with input from user in Shiny APP
I also tried using the selector for the input using the solution given here: Link R shiny selectInput item to open file actionButton
I am not sure if I am searching for the right solution here.
I also tried to use useShinyjs() and then onclick function on the server side but did not work.
Any help would be really appreciated.
Thank you!