【问题标题】:tweeting out of R console从 R 控制台发推文
【发布时间】:2017-05-19 08:16:04
【问题描述】:

我尝试使用此代码从我的 R 控制台发布推文

    library("RCurl")
opts <- curlOptions(header = FALSE, 
                    userpwd = "username:password", netrc = FALSE)

tweet <- function(status){
  method <- "http://twitter.com/statuses/update.xml?status="
  encoded_status <- URLencode(status)
  request <- paste(method, encoded_status, sep = "")
  postForm(request,.opts = opts)
}

tweet("This tweet comes from R! #rstats")

但是得到这个错误:raw(0) 警告: 在 postForm(request, .opts = optss) 中:没有输入传递给表单。

有人可以帮助我吗?在http://blog.revolutionanalytics.com/2009/06/tweeting-from-r.html找到代码

非常感谢

【问题讨论】:

标签: r twitter


【解决方案1】:

Twitter 在 2010 年禁用了基本身份验证方案。这不再有效。您必须使用 OAuth2-Authentification。

这里最简单的方法是 CRAN 上提供的 twitteR-Package。

第一步:认证:

consumer_key <- "yourcredentials"
consumer_secret <- "yourcredentials"
access_token <- "yourcredentials"
access_secret <- "yourcredentials"
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)

您必须在 Twitter 上设置 API-APP 才能获取密钥:https://apps.twitter.com/

在这一步之后,它与您的问题相同:

tweet("Hello World")

每日限制为 2400 条推文。

【讨论】:

    猜你喜欢
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 2016-05-22
    • 2021-02-27
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多