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.
Related
I am trying to get events for a meetup. The problem is I am only getting around 200 events. So, I tried doing an offset and specifying the pagination as specified in other stackoverflow question but is not working. It is giving me the same records each time. Can anyone advise on how to get other records? Thanks so much. Below is the R code.
library(jsonlite)
data1<- data.frame(fromJSON("https://api.meetup.com/bostonphp/events?key=yourkey&status=past&page=40&offset=7", flatten = TRUE))
Disclosure that I wrote the package meetupapi that I reference in my answer.
installation
Currently the development version on github is recommended because I've yet to submit some bug fixes to CRAN.
devtools::install_github("zacdav/meetupapi")
Get meetup events
library(meetupapi)
api_key = "************API_KEY_HERE***************"
boston_events <- get_meetup_events("bostonphp", api_key)
I am working in R with the twitteR package, which is meant to get information from Twitter through their API. After getting authentificated, I can download information about any user with the getUser function. However, I am not able to do so with usernames which are only numbers (for example, 1234). With the line getUser("1234") I get the following error message:
Error in twInterfaceObj$doAPICall(paste("users", "show", sep = "/"),
params = params, : Not Found (HTTP 404).
Is there any way to get user information when the username is made completely of numbers? The function tries to search by ID instead of screenname when it finds only numbers.
Thanks in advance!
First of all, twitteR is deprecated in favour of rtweet, so you might want to look into that.
The specific user ID you've provided is a protected account, so unless your account follows it / has access to it, you will not be able to query it anyway.
Using rtweet and some random attempts to find a valid numerical user ID, I succeeded with this:
library(rtweet)
users <- c("989", "andypiper")
usr_df <- lookup_users(users)
usr_df
rtweet also has some useful coercion functions to force the use of screenname or ID (as_screenname and as_userid respectively)
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?
This question has been asked many times for php, C# and some other programming languages. I don't find any information for R though and I can't derive a solution from the other topics.
I try to do facebook data mining in R with the package Rfacebook:
library(devtools)
install_github("pablobarbera/Rfacebook/Rfacebook")
require("Rfacebook")
fb_oauth <- fbOAuth(app_id="ID", app_secret="SECRET",extended_permissions = TRUE)
After authenticating, facebook already gives me an error (though I'm not sure, if it has anything to do with the problem):
For starters, I'd like to access my own profile now:
myProfile <- getUsers("me",token=fb_oauth)
and that's when the console display the following error:
An active access token must be used to query information about the current user.
How can I fix this?
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.