I just received a public and private key to connect to ICObench api. I'm quite used to use R, but I admit i found no accurate info on how to authenticate to an API that asks for a public an private key.
Here is their api page telling how to authenticate (though not with R).
I tried the following code (using httr package), which i found on this stackoverflow post :
req <- GET("https://icobench.com/api/v1/icos/ratings",
authenticate("user#gmail.com" , "password"),
add_headers(privateKey = privatekey ),
add_headers(publicKey = publickey))
stop_for_status(req)
content(req
)
But this code does not seem to work with 2 keys/2 headers. I get the following error message :
"Not provided or missing X-ICObench-Key"
Any idea how to authenticate properly to this API ? There's some nice tutorials for the rest :)
Thanks for your help
You can give the following a try
signature <- openssl::base64_encode(openssl::sha384("", privateKey))
req <- GET("https://icobench.com/api/v1/icos/ratings",
authenticate("user#gmail.com" , "password"),
add_headers("X-ICObench-Sig"=signature),
add_headers("X-ICObench-Key"=publickey))
stop_for_status(req)
content(req)
Related
I am trying to retrieve tweets from twitter on a full archive basis. However, I finally managed to work things out on my developer page, but the code seems to stumble upon an error that I can not find anywhere on the internet. This is my code without my tokens:
install.packages("RCurl")
library("RCurl")
install.packages("rtweet")
library("rtweet")
consumer_key <- ".."
consumer_secret <- ".."
access_token <- ".."
access_secret <- ".."
app <- "..."
token = rtweet::create_token(app,consumer_key,consumer_secret,access_token,access_secret)
dataBTC1 <- search_fullarchive("Bitcoin", n = 1000, env_name = "Tweets", fromDate = "201501010000")
And this is the error I get:
Error in tweet(x$quoted_status) :
Unidentified value: edit_history, edit_controls, editable.
Please open an issue and notify the maintainer. Thanks!
Literally no idea what it means and how to solve it if possible. Can anyone help me?
Thanks!
These errors occur because the R package you are using (rtweet) does not "know" about the three new fields that were added to the Tweet object when the new editable Tweets feature was released. You will need to ask the rtweet maintainers (as it mentions in the error message) to enable support for these fields in their library, or find an alternative way to call the API.
It appears that Yahoo has discontinued support for oauth1.0. I am trying to update my R code to use oauth2.0 using the httr package, and am stumped. I am able to get token, but am unable to use the token to query the api.
I continue to get "You are not authorized to view this league".
options("httr_oob_default" = T)
library(httr)
b_url <- "https://fantasysports.yahooapis.com" #base url
#Create Endpoint
yahoo <- httr::oauth_endpoint(authorize = "https://api.login.yahoo.com/oauth2/request_auth"
, access = "https://api.login.yahoo.com/oauth2/get_token"
, base_url = b_url)
#Create App
yahoo_app <- httr::oauth_app("yahoo", key=cKey, secret = cSecret,redirect_uri = "oob")
#Open Browser to Authorization Code
httr::BROWSE(httr::oauth2.0_authorize_url(yahoo, yahoo_app, scope="fspt-r"
, redirect_uri = yahoo_app$redirect_uri))
#Code = zp6v82a
#Create Token
yahoo_token<- httr::oauth2.0_access_token(yahoo,yahoo_app,code="zp6v82a")
Now im not sure where to go from here.
If there is any advice, or an easier method please let me know. I am an amateur coder so please, be gentle.
I am trying to extract all the posts from this year from a Facebook page using the Rfacebook package.
However, for the page that I need I get this error:
"Error in callAPI(url = url, token = token) :
Unsupported get request. Object with ID 'XXXXX' does not exist,
cannot be loaded due to missing permissions, or does not support this operation.
Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api"
This is the command that I used:
datafb <- getPage('XXXXX', token, n = 1000, since = '2017/01/01', until = '2017/04/01',
feed = TRUE)
I am sure the page exists, because I can access it from my Facebook account.
Also, the token is valid because it works when I try for other pages.
I really can't see what's wrong. Does anyone have any idea?
I'm trying to do some web scraping from steamspy.com, specifically the total playtime hours for a certain game. That info is behind the login wall for the site, so I've been trying to figure out how to get R past it for html mining.
I tried this method for passing login credentials via POST() but it doesn't seem to work. I noticed that the login handler for that example used POST, whereas looking at the source code for steamspy it seems to use a challenge form and I wasn't sure how to proceed with R.
My attempt thus far looks like this:
handle <- handle("http://steamspy.com")
path <- "/login/"
login <- list(
jschl_vc = "bc4e...",
pass = "148..."
)
response <- POST(handle = handle, path = path, body = login)
I found the values for the jschl_vc and pass from inspecting the source code after I logged in. The code above doesn't work and gives me:
Error in curl::curl_fetch_memory(url, handle = handle) : Failure
when receiving data from the peer
probably since I'm tryign to use POST to a challenge form. Is there way that I'm missing to proceed?
I am using RFacebook package to do data mining.
For example, to get the facebook page then we do
fb_page <- getPage(page="facebook", token=fb_oauth)
In my case is it is a private group and the URL is something like this. So how do I get the page info for a group? I tried the following but got the following error.
Error in callAPI(url = url, token = token) : Unknown path
components: /posts
my_page <- getPage(page="group/222568978569", token=my_oauth)
This isn´t a reproducible example because the page you mention doesn´t exist. But I suggest that you check that this group has authorized your app. Note that after the introduction of version 2.0 of the Graph API, only friends/groups who are using the application that you used to generate the token to query the API will be returned.