Last active
August 29, 2015 14:23
-
-
Save tts/ebff8ab00ae367635a2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(httr) | |
| alchemy_url <- "http://access.alchemyapi.com/" | |
| call <- "calls/text/TextGetRankedConcepts" | |
| api_key <- "[your API key here]" | |
| text <- "Indeed the Environment Agency inform us that these guidelines have been used as the basis of several hundred appraisals for the ongoing WaterIndustry Price Review process 10" | |
| # The following doesn't work. 'Status: 404, Content-Type: <unknown>' | |
| # | |
| # q <- paste0(alchemy_url, call, "&apikey=", api_key, "&text=", URLencode(text)) | |
| # | |
| # POST(q, | |
| # add_headers("Content-type" = "application/x-www-form-urlencoded" ), | |
| # verbose()) | |
| # However, this works | |
| # Thanks http://stackoverflow.com/questions/26001012/how-to-structure-httr-post-request-to-return-site-data | |
| url <- paste0(alchemy_url, call) | |
| r <- POST(url, | |
| query = list(apikey = api_key, | |
| text = URLencode(text))) | |
| # But - actually I shouldn't URLencode text, so final version: | |
| r <- POST(url, | |
| query = list(apikey = api_key, | |
| text = text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment