pablobarbera / rfacebook Goto Github PK
View Code? Open in Web Editor NEWDev version of Rfacebook package: Access to Facebook API via R
Home Page: http://cran.r-project.org/web/packages/Rfacebook
Dev version of Rfacebook package: Access to Facebook API via R
Home Page: http://cran.r-project.org/web/packages/Rfacebook
Hi Pablo,
The searchFacebook is not working for version 2.0 or higher. When will this problem be resolved ? And if not how can we generate access token for version 1.0 ?
e.g. getLikes returns:
Error in content$likes$data : $ operator is invalid for atomic vectors
Hello,
First of all, thank you very much for the package. However I got an issue when i try to get my token. The first time I use it, I got this log :
fb_oauth <- fbOAuth(app_id="Myid", app_secret="myid",extended_permissions = TRUE)
Copy and paste into Site URL on Facebook App Settings: http://localhost:1410
When done, press any key to continue...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error: Deprecated: supply token object to config directly
When I try to type again the fbOAuth, nothing happens except the last line : Error: Deprecated: supply token object to config directly
Facebook confirmed it was ok on mybrowser and I set the localhost in my application setting. I didnt see anyone having the same issue but me. Did I do something wrong ?
Hello Pablo,
first of all, tnx for your work..this package is really a lifeboat, to me!
Said that, I must say that I'm not able to make getInsights working. Whatever parameters I put, I always get this error: Error in content$data[[1]] : subscript out of bounds
Some examples ->
From a page I own:
circle <- getInsights(object_id="9thcirclegames", token = fb.connection, metric = "page_impressions")
circle <- getInsights("me", token = fb.connection, metric = "page_impressions")
A post by me (not the page):
example_post <- circle <- getInsights(object_id="10152670074275267_10152659686895267", token = fb.connection, metric = "post_impressions", period='days_28')
perhaps I'm using the function in the wrong way?
Despite recent updates and compatibility with 2.0 API, the package doesn't work for me.
For example, the basic line "me <- getUsers("me", token=token)" returns : 'could not find function "getTokenVersion"'.
Any idea ? 👍
I have read that facebook made some api changes on the 30 of april, after researching for a while i found
http://thepoliticsofsystems.net/2015/01/the-end-of-netvizz/
So, im not sure that with this R library i cant do it still.... Can i? What version of the facebook API does it uses. I was actually using the get net plugin made for SNA course.
Do you have some comments about this?
Is there a reason that the period of time counts forward instead of backwards when using period='day', n=15?
metric_name period values end_time
1 page_stories day 42 2015-04-12T07:00:00+0000
2 page_stories day 25 2015-04-13T07:00:00+0000
3 page_stories day 14 2015-04-14T07:00:00+0000
4 page_stories day 14 2015-04-15T07:00:00+0000
5 page_stories day 14 2015-04-16T07:00:00+0000
6 page_stories day 7 2015-04-17T07:00:00+0000
7 page_stories day 0 2015-04-18T07:00:00+0000
8 page_stories day 0 2015-04-19T07:00:00+0000
9 page_stories day 0 2015-04-20T07:00:00+0000
10 page_stories day 0 2015-04-21T07:00:00+0000
11 page_stories day 0 2015-04-22T07:00:00+0000
12 page_stories day 0 2015-04-23T07:00:00+0000
13 page_stories day 0 2015-04-24T07:00:00+0000
14 page_stories day 0 2015-04-25T07:00:00+0000
15 page_stories day 0 2015-04-26T07:00:00+0000
Thank you for fixing getInsights!
Why the function is only returning less than 10 friends?
Hey Pablo,
I followed the instructions for signing up on facebook and got an API key and app_secret as mentioned in the walkthrough at http://thinktostart.com/analyzing-facebook-with-r/.
After using the fbOAuth function and pasting the url provided by the function into the "Site URL" in my app account settings I am getting the following error message:
"Invalid Scopes: read_stream. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions"
Any help on how to get around this would be helpful as I have searched all over and can't find a solution anywhere.
Brandon
Is there any way to get a list of people who shared a specific post? The function getPost just returns a list of people who liked or commented a post.
This doesn't seem to be available with the current version of the API, but I'll implement it if that changes.
Going through the documentation and trying to pass specific data using parms in getInsights.
Not working. Must be doing something wrong. Would it help to add this as an example in the documentation?
getInsights(object_id="12345" ,token=token ,parms =c( "&since=2015-05-01T00:00:00%2B0000&until=2015-05-31T00:00:00%2B00000") ,metric='page_stories' ,period = "day")
So I finally found a way to get insights from pages I manage, but I have to make a call for any single metric I want to analyze.
It'd be nice to get a way to pull multiple metrics under one command and also to have a command for pulling all the possible metrics we have available to analyze.
Thank you in advance!
Hi,
When i make a call such as:
getInsights(object_id="XXX", fb_access_token, metric = "post_interests_impressions_unique")
I get the below error:
Error in names(tmp) <- c("value", "variable") :
'names' attribute [2] must be the same length as the vector [1]
Looks like maybe the api response structure might be causing issues for the function.
Seems to only happen for insights in the "post_interests_..." family.
Please when I use rfacebook authentication in trying to connect to facebook from R I get this error message
Invalid Scopes: friends_birthday, friends_hometown, friends_location, friends_relationships, user_checkins, friends_status, friends_checkins, friends_likes, export_stream. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions
Please could you please explain what the problem is. Initially I was able to log in with no problem. I suspect this problem started after the facebook graph API was upgraded to Version 2. I may be wrong. Julain from the Think To Start forum suspects it maybe a bug in the rfacebook package. As a result, he directed me to you.
I hope you can resolve it cause I need to pull some data from facebook into R.
Thank you
Richard
Thanks for such a great tool. When I ran the following code:
> page <- getPage("humansofnewyork", token, n = 5000)
The following message is output, although in the vignette there does not appear to be a limit on the number of posts which can be requested:
100 posts
Error in callAPI(url = url, token = token) :
Please reduce the amount of data you're asking for, then retry your request
Are there any strategies to request a large number of posts without encountering this message?
Hi,
I was trying to use the getNewsfeed function. Irrespective of the value I give for n, it is only retrieving posts in the last 2 days or so (around 158 posts). Is there a limit on how many days of data will be pulled?
Thanks!
Minu
Sometimes, searchFacebook() does not find a keyword then throw a message
"No public posts mentioning the string were found" which is OK but in a shiny app, It is not convenient to stop app when a keyword is not found.
So It should return an empty dataframe
Hi Pablo,
I'm getting this message from the getPage() function:
Error: is.request(y) is not TRUE
I googled the error and it seems it is a httr
issue, as they have recently updated the package to 1.0.0 version.
I've noticed that the function gives unconsisted results depending on page.
Reproducible Example:
getPage("IndesitItalia", fb.conn, n = 2)
--> It returns a parent list of 2 parent post_id elements and a sublist of three elements each inside them (post, likes, comments)
getPage("tods", fb.conn, n = 2)
--> It return a list of six elements (post1, comments1, likes1, post2, comments2, likes2) impossible to parse
I suspect something wrong in escaping some unicode characters...
tnx for support and have a nice day!
Nice package - thanks!
However, I can't OAuth. R crashes on fbOAuth(app_id="123456789", app_secret="1A2B3C4D")
, i.e. the executable freezes after I got my ok from facebook.com. The last Rgui line says "Starting httpd help server .... done".
My system info: R version 3.0.2 (2013-09-25), Platform: x86_64-w64-mingw32/x64 (64-bit), httr 0.2, Rfacebook 0.3, Rook 1.0-9, brew 1.0-6.
load("fb_oauth")
d <- getFQL("SELECT uid2 FROM friend WHERE uid1=me()", token=fb_oauth)
getFQL <- function(query, token){
# cleaning text of query
query <- gsub(" ", "+", query)
url <- paste0('https://graph.facebook.com/fql?q=', query)
# making query
content <- callAPI(url=url, token=token)
return(content$data)
}
when i run that program, i have error: it could not find function: "callAPI". thanks a lot. that is the error message.
Error in getFQL("SELECT uid2 FROM friend WHERE uid1=me()", token = fb_oauth) :
could not find function "callAPI"
Thanks for this wonderful package.
I'm having a little trouble getting data from getInsights() from pages our Business Manager is either admin or owner.
Using this code from a token issued by the BM owner account,
load("/Users/jramirezcastillo/Documents/media_auth")
me <- getInsights(object_id = "227015499643", token = medialab_auth,
metric = "page_posts_impressions", period = "lifetime")
Which returns:
me <- getInsights(object_id = "227015499643", token = medialab_auth,
Error in getInsights(object_id = "227015499643", token = medialab_auth, :metric = "page_posts_impressions", period = "lifetime")
No data available. Are you the owner of this page? See ?getInsights.
Hi,
I tried to register a new app on FB, but when trying to register http://localhost:1410
, I got this error :
This must be derived from Canvas URL, Secure Canvas URL, Site URL, Mobile Site URL, Page Tab URL or Secure Page Tab URL. Check and correct the following domains: localhost
Did I miss somehting obvious, or did FB recently change its policy, and therefore would Rfacebook need to change its authentification method?
Cheers!
Joel
Hi,
I was trying to execute the getnetwork function and was getting the following error. Its the same error when I try to run getfriends function as well.
Error in matrix(unlist(content$data), ncol = 2, byrow = TRUE) :
'data' must be of a vector type, was 'NULL'
I think the error was occurring due to CALLAPI function. Can someone help in fixing the issue.
This is the set of lines that i tried to execute.
token <- 'my token here'
network <- getNetwork(token, format="adj.matrix")
Dear Pablo.
I have been trying to pull data from facebook into R using the Rfacebook package but I keep getting the following error
"Error in callAPI(url = url, token = token) :
An unexpected error has occurred. Please retry your request later."
I switched to using a temporary authentication token when I started having issues with the permanent token again (which had issues initially and then you advised me to include the "extended_permissions=FALSE" parameter in the fbOAuth command which I did and it worked fine for a while until a few days ago).
In switching to the temporary authentication token it pulled data for a few posts into R from FB before given me the error above.
Please what could the problem B as I have just 2 days left to meet a deadline.
Thanks for your usual and appreciated attention.
Hi.
Please could you help me why just got 9 connections. Do I have some configuration to make on facebook before doing this.?
Only friends who use the application will be returned
my_friends <- getFriends(token, simplify = TRUE)
Only friends who use the application will be returned
See ?getFriends for more details
Thanks.
Regards.
Fernando.
Hi Pablo,
I´d like to retrieve data for the "page_impressions_by_country_unique" metric over a large period of time, let say 6 months.
When I run the query with a period of 2 months, it seems to work fine. E.g:
data<-getInsights(object_id="xxx", token, metric="page_impressions_by_country_unique", period = "day",parms="&since=2015-01-01&until=2015-02-28")
However if the period gets larger, e.g.:
data<-getInsights(object_id="xxx", token, metric="page_impressions_by_country_unique", period = "day",parms="&since=2015-01-01&until=2015-03-31")
I get the following error:
Error in data.frame(unlist(x$data[[1]]$values[[i]]$value), end_time = x$data[[1]]$values[[i]]$end_time, : arguments imply differing number of rows: 0, 1
Or in other cases, I get an error saying "Invalid Token".
I am using a temporary token. Do you have any idea why I can´t get the data?
Thank you very much,
Marco
See #47
When the function is called, it says: "Error: object 'sincedate' not found"
Hi,
The getNetwork function is giving an error:
The command- mat <- getNetwork(token, format="adj.matrix")
Error in callAPI(query, token) :
(#12) user/mutual_friends is deprecated for versions v2.0 and higher
I know that facebook has changed its API which is causing this error. Have anybody figured out any workaround for this? Please a little help is appreciated.
Thanks.
Fixed issue #8 (49db037) changed the code for the searchFacebook function so that an empty data frame, rather than a 'stop' command, was returned when no posts were found. Is it possible to change the getGroup function in a similar way? If the current function is used within a loop, the loop will stop at the first group_id that does not have any content.
Hi,
Would be nice if the getInsights()
could work with the page_views_external_referrals
metric.
Today, when I try, I get:
teste <- getInsights(object_id = "1522614931338640", token = fb_oauth, metric = c('page_views_external_referrals'),
period = c('day'), parms= paste0("&since=", last_month_s, "&until=", fblast_month_e))
Error in data.frame(unlist(x$data[[1]]$values[[i]]$value), end_time = x$data[[1]]$values[[i]]$end_time, :
arguments imply differing number of rows: 0, 1
I think that it is a nice metric to show what sites are important to the fan page.
Thanks!!
I'm trying to authenticate a Facebook session from RStudio Server but when I try to connect to authenticate in browser (http://localhost:1410/), I cannot connect as connection is refused.
Anyone else got this problem? Tried using the local machine token file but got the same problem.
Hi,
getUsers in Rfacebook is throwing following error.
Command Used: me <- getUsers("me", token=fb_oauth)
Error message: Error in callAPI(query, token) :
(#12) username is deprecated for versions v2.0 and higher
Has facebook disabled call back by this API. Is there any alternate way.
Thanks
Hi, Pablo,
In the user document, it said that "Note that information about users that
have turned on the "follow" option on their profile can also be retrieved with this function."
Did you mean that there is a parameter with the function "getPage"?
Thanks!
As referenced in issue #52,
I've been playing with the function last night and found that getInsights work with mostly all the metrics stated here.
From Page Video Posts downwards I couldn't get any data.
Referenced link: https://developers.facebook.com/docs/graph-api/reference/v2.1/insights
When called, it says:
Error in callAPI(url = url, token = token) :
(#11) Post search has been deprecated
Hi Pablo - thanks for all your support over the Christmas period. I have just fired up RFacebook again and have the problem below:
getUsers("xyz", fb_oauth, private_info = TRUE)
Error in make_request("get", hu$handle, hu$url, config) :
attempt to apply non-function
Any idea what this means?
A
Edit; here are the issues I have:
I have added the app and pasted the localhost link in Add Platform.
First time it ran and pop up an authorization browser. I gave access.
Then when it traverse to the next time (after i press enter), it throws me the following error
Error in withCallingHandlers
object '.rcpp_warning_recorder not found.
But it says connection problem.
I think what is happenning is as the code does not traverse, it is not creating a localhost server. But i dont know How to fix this issue.
The getPost function does not support singular statuses anymore.
Hello,
First of all congratulations for this great package.
I am wondering how to crawl contents from 'group' pages, such as for example: www.facebook.com/groups/Epilepsyawareness/
Is that feasible? Would it be feasible to develop a 'getGroup' function similar to getPage to complete this task?
Thank you very much in advance for your views on this!
Best regards
Pablo Hi,
Please I have been trying to extract posts/comments in the reviews section of public facebook pages to no avail.
Please which of the commands in the Rfacebook package can extract data successfully from the reviews section
Thank You
Richard
Hi,
First, thanks for this good and useful package!!!
I'm trying to get info about post_consumptions_by_type, but when I try, I get back a NULL object only, no error, no list, only test as a NULL object.
test <- getInsights(object_id='1522614931338640_1678950812371717',
token=fbtoken, metric='post_consumptions_by_type', period='lifetime')
I tried some other post metrics as:
post_storytellers
post_stories
post_impressions
The result is the same.
In the Graph Explorer, I did:
GET /2.5/1522614931338640_1678950812371717/insights/post_consumptions_by_type
And I receive:
{
"data": [
{
"name": "post_consumptions_by_type",
"period": "lifetime",
"values": [
{
"value": {
"other clicks": 43,
"link clicks": 46
}
}
],
"title": "Lifetime Post Consumptions by type",
"description": "Lifetime: The number of clicks anywhere in your post, by type. (Total Count)",
"id": "1522614931338640_1678950812371717/insights/post_consumptions_by_type/lifetime"
}
],
I tried using the temporary token (the same used in the Graph Explorer) and the fb_oauth with the same results.
I'm using the wrong syntax? Work for others?
Thanks!
Hi Pablo,
When i run
getLikes('pagename', token)
I get
Error in content$likes$data : $ operator is invalid for atomic vectors
Do you know what's going on here?
Thanks
Felipe
Hi,
Very excited to see this new package. I have a shiny app which creates plots. I would like to publish those charts onto Facebook. Is it possible through your package. If not, can you suggest a way. I think the Graph API in Facebook allows such functionality.
Thank you,
SD
I saw here https://github.com/RanaivosonHerimanitra/Rfacebook/blob/master/Rfacebook/R/searchFacebook.R that one can query a vector of string but when I try : searchFacebook(string=c("world","cup"), token=oauth,n=50)
but also this one:
searchFacebook(string="world cup", token=oauth,n=50)
It always gives me :
Error in fromJSON(rawToChar(url.data$content)) : unexpected character '<'
Or this :searchFacebook(string=c("cup"), token=oauth,n=50)
works fine
Edit:
Same error here:
posts <- searchFacebook(string = "upworthy", token=oauth, n = 500,
since = "25 november 2013 00:00", until = "25 november 2013 23:59")
Error in fromJSON(rawToChar(url.data$content)) : unexpected character '<'
Hey guys, all my respect to pablobarbera for this great Rfacebook package !!!
Since today, I get the following error after requesting:
pagefansbycountry <- getInsights(object_id=FBPAGENAME, tok .... [TRUNCATED]
Error in getInsights(object_id = FBPAGENAME, token = fb_oauth, metric = "page_fans_country", : No data available. Are you the owner of this page? See ?getInsights.
Before, it was possible to get the page_fans_country, even if you're not the owner of the page.
Could you please bring this function back? It was very useful!
It would be a pleasure helping you testing!
All the best,
David
Hi Pablo,
This is in continuation to my previous issue #21 to which you commented that facebook has withdrawn access to public post search; I just want to ask on thing.
Could you please suggest some other method in R to search public posts from Facebook. And if not R then could you please some other method by which I can fetch public posts from facebook either paid or free?
Thanks
After running fbOAuth i got something like that:
In class(fb_oauth)[4] <- "v2" :
Defined class(x) for multiple strings ("Token2.0", "NA", ...); result will no longer be an object S4.
Can you explain to me what's going on? I've read a lot and tried all possible solutions but none of then worked for me.
Best,
Armando Neto
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.