2

我正在尝试在 R 中的 Windows 7 中复制以下 apigee oauth 调用。我尝试了 Roauth、(python)oauth-proxy 和 RCurl(可能是最好的方法,但我无法弄清楚)等。这是运行良好的 apigee 调用:

GET /places/geocode?geo=%7B%22%24point%22%3A%5B34.06021%2C-118.41828%5D%7D HTTP/1.1
Authorization:
OAuth oauth_consumer_key="myKey",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1372529150",
oauth_nonce="1274556232",
oauth_version="1.0",
oauth_signature="someSignature"
Host: api.v3.factual.com
X-Target-URI: http://api.v3.factual.com
Connection: Keep-Alive

我需要一个保持打开状态的 oauth 连接,以便我可以在 R 中调用 API。任何帮助都将不胜感激,特别是上述字段如何读入解决方案。提前感谢您的宝贵时间。

4

1 回答 1

1

抱歉,我没有得到您的确切要求,该方法现已弃用(http://developer.factual.com/api-docs/#Geocode)。好消息是连接到新的 geotag API 调用看起来更容易,并且不需要 OAuth 来回 ( http://developer.factual.com/api-docs-v4/#Geotag )。以下是您的 Apigee 请求在 V4 中的样子:

require(httr)

## Factual credentials
consumerKey <- "" ## your API key from Factual

## geotag demo - V4 API
geotag <- GET(paste0('https://api.factual.com/geotag?latitude=34.06021&longitude=-118.41828&KEY=',consumerKey))
content(geotag)

不过,我假设连接到 Factual 的其他端点仍然是一个有趣的问题。就在今天早上,我根据Using the Yelp API with R 的答案来工作,尝试使用 geo-coordinates 搜索业务类型

我只是在此处显示地点类别,但也使用此签名连接到已阅读地点。

require(httr)

## Factual credentials
consumerKey <- "" # your key
consumerSecret <- "" # your secret

## authorization
myapp <- oauth_app("Factual", key=consumerKey, secret=consumerSecret)
## R will ask to cache credentials between these lines
sig <- sign_oauth1.0(myapp)

data <- GET('https://api.v3.factual.com/t/place-categories?limit=500',
sig)
content(data)
于 2015-01-14T18:47:58.287 回答