本文介绍了我如何在一个闪亮的应用程序中嵌入Twitter时间线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

难以在Twitter应用中嵌入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);}}(文件, 脚本, 推 - WJS );')),
titlePanel(),
sidebarLayout(
sidebarPanel()
,mainPanel(
a(Soccer,class =twitter-时间线
,href =https://twitter.com/pssGuy/timelines/524678699061641216
,data-widget-id=524686407298596864)



,server =函数(输入,输出,会话){

}




希望嵌入

解决方案

编辑包含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 ,图标=图标(globe)),
menuItem(空标签,tabName =空,图标=图标(信息圈))

),
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 = / ^ h 。TTP:/测试(d.location)\'http\ ':\'https\';(!d.getElementById(ID))如果{JS = d.createElement(一个或多个); js.id = ID; js.src = p + ://platform.twitter.com/widgets.js; fjs.parentNode.insertBefore(JS,FJS);}}(文件, 脚本, 推 - WJS); ')),
列(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)
)))
$ b)))
,server = function(input ,输出,会话){

}



Having difficulty embedding a twitter timeline into a shiny app.

tried to follow this code

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

}
)
)

but now that twitter has changed the way they produce widgets i cant figure out how to get w new data widget id. Not super familiar with HTML or JS so any help would be appreciated!

hoping to embed the timeline of "https://twitter.com/CityOfBoston"

解决方案

Edited to include OP comments on re-formatting as a shiny dashboard page with tabs. I don't think you need the data-widget-id anymore. This loads the timeline for me.

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

                }
        )
)

这篇关于我如何在一个闪亮的应用程序中嵌入Twitter时间线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 04:28