我有一个闪亮的应用程序,其中包括一个小工具,以分享一些预先加载的文本推文。它在应用程序上显示为一个按钮,上面写着"Tweet“,发送位于代码的标签$div部分的data-text行中的文本。我也希望能够在人们在线使用这个闪亮的应用程序时创建的推文中包含一张ggplot图表的图像。
这有可能吗?我看到有人建议使用Twitter卡片,但我对此并不熟悉,也不知道如何在这个工具中使用Twitter卡片。
下面是我的最小reprex。如果你想看到完整的应用程序,你可以在ffvaluator.com/tools/draftevaluator上找到。
用户界面:
ui <- fluidPage(
mainPanel(
plotOutput("draftPlot"),
tags$div(
HTML("<div style='float:right'>
<a href='https://twitter.com/share'
class='twitter-share-button'
align='middle'
data-url='www.mywebsite.com'
data-text='Insert text here!'
data-size='large'>Tweet
</a>
<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');
</script>
</div>")
)) )服务器:
server <- function(input, output) {
output$draftPlot <- renderPlot({
ggplot() +
geom_smooth() +
geom_point()
})
}我也在RStudio社区网站(这里是:https://community.rstudio.com/t/attach-ggplot-image-to-tweet-through-twitter-share-widget-in-shiny-app/67867)上发布了这篇文章,但还没有得到任何回应。
发布于 2020-05-29 21:50:02
不幸的是,Twitter web分享弹出窗口(twitter.com/share)无法包含图片。Twitter Card的工作方式是,如果您在Tweet文本中共享指向静态网页的链接,并且该页面具有包含图像的标记,则图像将显示为链接的预览。我不熟悉闪亮,至于这是否可以在这里工作。
https://stackoverflow.com/questions/62086843
复制相似问题