【问题标题】:Using R for oauth with factual使用 R 进行 oauth 与事实
【发布时间】:2015-01-15 02:47:58
【问题描述】:

我正在尝试在 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。任何帮助都将不胜感激,特别是上述字段如何读入解决方案。提前感谢您的宝贵时间。

【问题讨论】:

    标签: r oauth rcurl


    【解决方案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, attempting to search business types using 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-14
      • 2022-01-03
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多