我正在尝试使用api.xing.com (v0.9.2)对XING (api.xing.com)进行身份验证。
library(package="RCurl")
library(package="ROAuth")
site <- "https://api.xing.com"
requestTokenPath <- "/v1/request_token"
accessTokenPath <- "/v1/access_token"
authorizePath <- "/v1/authorize"
consumerKey <- "***********" # blank key for posting
consumerSecret <- "********" # blank key for posting
requestURL <- paste(site, requestTokenPath, sep="")
accessURL <- paste(site, accessTokenPath, sep="")
authURL <- paste(site, authorizePath, sep="")
credentials <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=requestURL,
accessURL=accessURL,
authURL=authURL,
needsVerifier=TRUE)
credentials$handshake(ssl.verifypeer=FALSE) # skip ssl verification for testing, this is passed through to RCurl输出:
Error in credentials$handshake(ssl.verifypeer = FALSE) :
Invalid response from site, please check your consumerKey and consumerSecret and try again.我检查了我的键和URL,所以我很确定这不是错误的原因。
谢谢,克里斯
发布于 2013-01-18 12:14:10
我建议使用Hadley的httr包,因为我发现它在处理API时特别有用。别忘了仔细阅读所有相关文件..。
它似乎使用了OAuth v1,所以请看相关的httr文档。
我不确定你是否已经认识this...but,这是一个两个阶段的过程.
首先,你把你的消费者钥匙和秘密发送到星,它会还给你一个令牌。
然后对所有这三个人:
( 1)使用者钥匙;( 2)使用者保密;( 3)刚才提供的令牌
但是,您能访问XING设置的所有API调用吗? up...you可能需要XML来高效地解释响应。
不确定这是否有效,但大致如下:
require(httr)
xing.app <- oauth_app("xing",key="xxxxxxxxxx", secret="xxxxxxxxxxxxxxx")
xing.urls <- oauth_endpoint(NULL, "authorize", "access_token",base_url = "https://api.xing.com/v1/")
xing.token <- oauth1.0_token(xing.urls, xing.app)
xing.token在xing.token中,该令牌用于该唯一的密钥和秘密组合,即user...but一旦有it...you就不需要一直请求it...you,可以将其存储在.Rprofile文件或something...and中,然后在GET或POST命令中将其作为选项引用。
user.signature <- sign_oauth1.0(xing.app, token = token.string.from.xing.token, token_secret = token.secret.from.xing.token)
# so I think as an example you can have this...
id <- "yyyyyyy"
GET(url= paste0("https://api.xing.com/v1/users/",id), config=user.signature)希望helps....there可能是代码中的一些错误,因为这是没有测试的,因为我没有您的使用者密钥或秘密。我还没有完全看过文档,但我不认为太远了,off...please可以自由地重新使用corrections...when,您实际上是在测试它.
out of curiosity...what,您是否在使用API?
https://stackoverflow.com/questions/14198411
复制相似问题