Description Usage Arguments Details Value Nesting fields Valid sources Author(s) See Also Examples
View source: R/FacebookUsersCollection.R
Connect to Facebook Graph API, get public information from a list of Facebook users
and build a FacebookUsersCollection-class
instance.
1 2 3 4 |
id |
A character vector or a comma-delimited string of IDs or an existing Facebook Collection of any of the supported types (see below). |
token |
Either a temporary access token created at
https://developers.facebook.com/tools/explorer or the OAuth token
created with |
parameters |
A list of parameters to be added to the Facebook Graph API query. For more information on the accepted parameters, see: https://developers.facebook.com/docs/graph-api/using-graph-api. |
fields |
A character vector with the fields to get for each |
n |
If |
metadata |
If set to |
.progress |
progress_bar object as defined in the plyr package.
By default the |
FacebookUsersCollection
is the constructor for the FacebookUsersCollection-class
.
It returns data about users.
After version 2.0 of the Facebook API, only id, name, and picture are available through the API as public informations. All the remaining fields will be missing unless the Application asks for specific permissions.
A collection of users in a FacebookUsersCollection-class
object.
Due to the network-graph nature of Facebook data model,
you can specify fields details for each field nesting .fields()
clauses.
For example, if you need only id
and source
for the cover
field, this is valid among others:
cover.fields(id,source)
.
Following the same philosophy, if you need only id
and name
for the from
node
you can use from.fields(id,name)
.
Instead of a character vector, one of these collections can also be passed as parameter in id
:
FacebookUsersCollection-class
will build a collection with
the friends of the users of the source collection. It assumes these users
have granted the user_friends
permission to the current application.
FacebookPostsCollection-class
will build a collection from
the authors of the posts of the source collection.
FacebookCommentsCollection-class
will build a collection from
the authors of the comments of the source collection.
FacebookLikesCollection-class
will build a collection from
the authors of the likes of the source collection.
FacebookUsersCollection-class
will build a collection with
the posts written on the walls of the users in the source collection.
FacebookGroupsCollection-class
will build a collection with
the members of the groups in the source collection.
FacebookMixedCollection-class
will build a collection with
only the user elements of the source collection.
Be careful when binding this kind of collection starting from a FacebookPostsCollection
, FacebookCommentsCollection
or a FacebookLikesCollection
.
In Facebook, one can publish, comment or like acting as a user or as a page. But since users and pages have different sets of fields and you won't know in advance if the author is a page or not, the constructor of this collection would fail due to inconsistent fields.
To avoid this, if id
is an instance of one of the aforementioned collections, a serialization query is performed
before to eventually filter out the pages and retain only the users. Finally, the real collection is built on this valid subset of user IDs only.
This requires more queries and, usually, more time.
Gabriele Baldassarre https://gabrielebaldassarre.com
FacebookPostsCollection
,
FacebookCommentsCollection
,
FacebookLikesCollection
,
facebook.search
Other Facebook Collection Constructors: FacebookAlbumsCollection
,
FacebookCommentsCollection
,
FacebookConversationsCollection
,
FacebookEventsCollection
,
FacebookGroupsCollection
,
FacebookLikesCollection
,
FacebookMessagesCollection
,
FacebookPagesCollection
,
FacebookPhotosCollection
,
FacebookPostsCollection
,
FacebookReactionsCollection
,
FacebookVideosCollection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
## See examples for fbOAuth to know how token was created.
load("fb_oauth")
## Getting information about 9th Circle Games' Facebook Page
fb.pages <- FacebookPagesCollection(id = c("9thcirclegames",
"NathanNeverSergioBonelliEditore"),
token = fb_oauth)
## Getting the commenters of the latest 10 posts
fb.comments <- fb.pages %>% FacebookPostsCollection(n = 10) %>%
FacebookCommentsCollection(fields=c("id",
"from.fields(id,name)"),
n = Inf)
## Build a collection of users from who actually commented those posts
fb.commenting.users <- fb.comments %>% FacebookUsersCollection()
## Convert the collection to a data frame
fb.commenting.df <- as.data.frame(fb.commenting.users)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.