难以将Twitter时间线嵌入到闪亮的应用中。
试图遵循此代码
library(shiny)
runApp(list(ui = fluidPage(
tags$head(tags$script('!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");')),
titlePanel(""),
sidebarLayout(
sidebarPanel()
, mainPanel(
a("Soccer", class="twitter-timeline"
, href = "https://twitter.com/pssGuy/timelines/524678699061641216"
, "data-widget-id" = "524686407298596864")
)
)
)
, server = function(input, output, session){
}
)
)
但是现在twitter已经改变了他们制作小部件的方式,我无法弄清楚如何获得新的数据小部件ID。不熟悉HTML或JS,所以任何帮助都会受到赞赏!
希望嵌入时间表“https://twitter.com/CityOfBoston”
答案 0 :(得分:3)
编辑将OP评论包含在重新格式化为带有标签的闪亮仪表板页面。
我不认为你需要data-widget-id
了。这会为我加载时间表。
library(shiny)
runApp(list(ui = dashboardPage(header=dashboardHeader(titleWidth=150,
title = "Title"),
sidebar=dashboardSidebar(width=150,
sidebarMenu(
menuItem("Twitter Timeline", tabName="twittertimeline", icon=icon("globe")),
menuItem("Empty Tab", tabName = "empty", icon=icon("info-circle"))
)
),
body=dashboardBody(
tabItems(
tabItem(tabName="twittertimeline",
fluidRow(column(width=12,
tags$head(tags$script('!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");')),
column(width=6, box(width=NULL, height=NULL,
a("Tweets by @CityOfBoston", class="twitter-timeline"
, href = "https://twitter.com/CityOfBoston"
)
)
)
))),
tabItem(tabName="empty",
fluidRow(column(width=12,
box(width=NULL,height=NULL)
)))
)))
, server = function(input, output, session){
}
)
)