阅读API指南后,我期待使用R中的httr包进行请求。
作为一个简单的测试,我希望通过语言获得功能,这应该是一个相对容易的调用。但是,即使我根据指南正确构建了URL,也未能成功。
通话网址为:
本示例中的密钥和随机数已被修改!
身份验证方法为oauth_signature
https://semantria.readme.io/v4.2.3/reference#authentication https://semantria.readme.io/v4.2.3/reference#checking-supported-features-by-language
library(httr)
oauth_url <- "https://api.semantria.com"
semantria <- oauth_app(appname = "semantria",
key = consumerKey,
secret = consumerSecret)
signature <- oauth_signature(url = oauth_url,
method = "GET",
app = semantria,
token = consumerKey,
token_secret = consumerSecret)
url <- modify_url(url = url,
path = "/features.json",
query = list(
oauth_consumer_key = oauth_consumer_key,
oauth_nonce = oauth_nonce,
oauth_signature_method = oauth_signature_method,
oauth_timestamp = oauth_timestamp,
oauth_version = oauth_version,
language = "en"
))
response <- GET(url)