我一直在与R合作,通过他们的API发布到tumblr。我使用R包tumblR。一切都适用于文字和链接帖子,但在尝试发布照片时我一直都会遇到错误。
不确定这里是什么问题,也许我插入照片链接的方式有些错误的语法?试图调试但无法解决它。希望你们能帮助我吗?
我也发布了文字和链接帖子的代码,也许你们中的一些人为自己看到了这个价值。
[R CODE]
require(tumblR)
require(httpuv)
### Authorize
consumer_key <-'key'
consumer_secret <- 'secret'
appname <- 'appname'
tokenURL <- 'http://www.tumblr.com/oauth/request_token'
accessTokenURL <- 'http://www.tumblr.com/oauth/access_token'
authorizeURL <- 'http://www.tumblr.com/oauth/authorize'
app <- oauth_app(appname, consumer_key, consumer_secret)
endpoint <- oauth_endpoint(tokenURL, authorizeURL, accessTokenURL)
token <- oauth1.0_token(endpoint, app)
sig <- sign_oauth1.0(app,
token = token$credentials$oauth_token,
token_secret = token$credentials$oauth_token_secret)
### Post Text
post(base_hostname = "blogname.tumblr.com", type = "text", state = "published", tags = 'tag',
body = 'this is the body', token = token, consumer_key = consumer_key, consumer_secret = consumer_secret)
# => Shows: "* Hostname was NOT found in DNS cache" but posts the textpost to tumblr
### Post Link
post(base_hostname = "blogname.tumblr.com", type = "link", state = "published", tags = 'tag', url_link= 'www.somelink.de',
title_link= 'linkTitle', description= 'this is the description', token = token, consumer_key = consumer_key, consumer_secret = consumer_secret)
# => Shows: "* Hostname was NOT found in DNS cache" but posts the linkpost to tumblr
### Post Photo
post(base_hostname = "blogname.tumblr.com", type = "photo", tags = "tag", caption_photo = 'photoTitle',
link = "http://bilder.bild.de/fotos/bde-logo-35166394/Bild/20.bild.png",
source_photo = "http://bilder.bild.de/fotos/bde-logo-35166394/Bild/20.bild.png", data_photo= NA,
token = token, consumer_key = consumer_key, consumer_secret = consumer_secret)
# => Shows the following error and doese NOT (!) post the photo:
# * Hostname was NOT found in DNS cache
# * Trying 66.6.41.23...
# * Connected to api.tumblr.com (66.6.41.23) port 80 (#0)
# > POST /v2/blog/blogname.tumblr.com/post HTTP/1.1
# User-Agent: RCurl
# Host: api.tumblr.com
# Accept: application/json
# Authorization: ...
# Content-Length: 490
# Content-Type: application/x-www-form-urlencoded
#
# * upload completely sent off: 490 out of 490 bytes
# < HTTP/1.1 401 Not Authorized (!!!!!!)
# < Server: nginx
# < Date: Sun, 22 Mar 2015 12:14:43 GMT
# < Content-Type: application/json; charset=utf-8
# < Transfer-Encoding: chunked
# < Connection: close
# * Closing connection 0
# Warning message:
# In if (class(token) != "Token1.0") stop("token must be a Token1.0 type") :
# the condition has length > 1 and only the first element will be used
# Error in fromJSON(http.connection(url, token, bodyParams, consumer_key, :
# error in evaluating the argument 'content' in selecting a method for function 'fromJSON': Error: Not Authorized
对于我所研究的内容,tumblr API可能只返回“401 Not authorized”,因为请求的语法不正确,它不必与授权(密钥,秘密等)本身相关。由于相同的凭据适用于文本和链接帖子,我认为它应该是一个不同的问题。
tumblR描述说我们是“data_photo”或“source_photo”,所以我猜其中一个的NA是可以的。无论如何都试过了。
感谢任何帮助,谢谢!
答案 0 :(得分:0)
tumblR的新版本(1.1)已经发布。
使用此版本:
感谢报道!