How do I use R to do a Google Custom search? I have the custom search engine id and the api key. I currently try to do this:
getURL("https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=searchterm")
and I get the following error:
Error in function (type, msg, asError = TRUE) : SSL certificate
problem: unable to get local issuer certificate
Though I am able to get the results in json when I do a get request in the browser. Any clue on whats happening?
httr package worked!!
library(httr)
query="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=SEARCH_TERM"
content(GET(query))
set ssl.verifypeer=TRUE in getURL
getURL("https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=searchterm", ssl.verifypeer=TRUE)
Related
I am fairly new to using APIs and trying to use the zendesk API now through R using the ZendeskR package. I belive I have connected to it however I keep getting the following error whenever I try to query it.
Here is my code:
library(zendeskR)
library(rjson)
zendesk(username, password, url)
ticket <- getTicket('20150')
The username, password and url are all variables that I have assigned the correct values.
The following error that I get when I run it is this:
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Please help as I am unsure on what this error means or what I am doing wrong.
Thanks.
TLS v1.1 is no longer accepted by Zendesk, please use TLS v1.2.
I had tried to access my FB token using the preliminary code shown by pablo over here :
https://github.com/pablobarbera/Rfacebook
However I get the following error message :
Error in callAPI(query, token) :
An active access token must be used to query information about the current user.
I used this code:
fb_oauth <- fbOAuth(app_id="14025", app_secret="5fdb6ef5776",extended_permissions = TRUE)
save(fb_oauth, file="fb_oauth")
load("fb_oauth")
I understand that I am not having access using my token despite authentication completion. Could someone please help.
Quick fix is just remove type = "application/x-www-form-urlencoded"
from fbOauth.R in RFacebook package. Because now Facebook returns response in JSON format.
I am using the RGA package to connect R and Google Analytics: http://cran.r-project.org/web/packages/RGA/RGA.pdf
I am trying to get the list of unsampled reports created for a view using:
list_unsampled_reports(account.id, webproperty.id, profile.id,
start.index = NULL, max.results = NULL, token)
It prompts the following error:
"Error: client error: (400) Bad Request
reason message locationType location
1 invalid parameter Invalid field selection segmentId parameter fields"
Can anyone advise?
Client Login is deprecated, you should use OAuth 2.0.
There is a recently updated Hello Analytics API tutorial that should guide you through the steps to get your application working.
The error is caused by a bug when specifying fields in the request to API (segmentId instead webPropertyId). This bug is already fixed.
I am trying to access Google Big Query with R, using the 'assertthat' and 'bigrquery' packages, following these instructions:
http://thinktostart.com/using-google-bigquery-with-r/#comment-22450
http://www.lunametrics.com/blog/2014/06/25/google-analytics-data-mining-bigquery-r/
The issue comes at the authentication step, I get directed to a code in the webbrowser, and when I paste the code in the terminal the following error appears:
Enter authorization code:
####CODE GOES HERE#####
Error en function (type, msg, asError = TRUE) :
Could not resolve host: accounts.google.com
I think that one possible issue is that we are behind a corporate firewall. While we do have access to the internet and I can install R packages, if I ping google.com from the terminal, I get an error. But I would like to know if any of you have found a solution to this kind of problem.
Thank you very much for reading this post. Any help is appreciated.
I found a solution to the issue. It was related to the corporate proxies. If I use the wifi for visitors I can run queries.
I am trying to pull data with Lending Club's API with R:
https://www.lendingclub.com/developers/lc-api.action
but I am unsure how to do it. This is what I have now but I keep getting an unauthorized error. I called Lending Club for API support because it did not specify where to put the API Key, unfortunately they do not have any support for their API. They said all the information is on the website.
I have an account with Lending Club and an API Key.
This is my code, I added an "&api-key=" because I have used something similar for a different API.
library(rjson)
library(RCurl)
library(jsonlite)
apikey <- "pP0tK321JWldXCMYHJ8VmIhMHuM="
url <- "https://api.lendingclub.com/api/investor/v1/loans/listing"
url <- paste0(url,"&api-key=",apikey)
getURL(url)
fromJSON(url)
output:
> getURL(url)
Error in function (type, msg, asError = TRUE) :
SSL certificate problem: self signed certificate in certificate chain
> fromJSON(url)
Error in download_raw(txt) : client error: (401) Unauthorized
If anyone has worked with Lending Club's API with R please give me some guidance. Thank you!
EDIT//
Thanks it works, I have another question regarding the "query" argument. I added a query "showall", but how do I add TRUE?
If you click the following link it will show the query options.
https://www.lendingclub.com/developers/listed-loans.action
rr <- GET("https://api.lendingclub.com/api/investor/v1/loans/listing",
add_headers(Authorization="key"), query = "showall")
I wrote a package to work with the Lending Club API which should make this problem easier for you. Try this:
install.packages("LendingClub")
library(LendingClub)
LC_CRED<- MakeCredential(investorID, APIkey)
ListedLoans(showAll=TRUE)$content
You can see a few more examples by reading the vignette:
vignette("LendingClub")
Getting SSL stuff properly configured with RCurl can be kind of messy. I recommend httr.
Rather than an API key, it looks like the service requires an authorization header. Follow the info on that page to generate one for your account.
Then, when you have the Authortization value, you can make your request like
library(httr)
rr <- GET("https://api.lendingclub.com/api/investor/v1/loans/listing",
add_headers(Authorization="Vkqakl1lAygRyXRwlKCOyHWG4DE"))
Since I don't have an account, i'm not sure what the response will be, but you should be able to access it with
content(rr)