FacebookConversationsCollection: Build a collection of Facebook inbox conversations

Description Usage Arguments Details Value Nesting fields Valid sources Author(s) See Also Examples

Description

Connect to Facebook Graph API, get information from a list of inbox conversations and build a FacebookConversationsCollection-class instance.

Usage

1
2
3
4
5
FacebookConversationsCollection(id, token = NULL, parameters = list(),
  fields = c("id", "snippet", "updated_time", "message_count"),
  n = getOption("facebook.maxitems"), metadata = FALSE,
  .progress = create_progress_bar(), stop.condition = function(x) {    
  FALSE })

Arguments

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 fbOAuth. If token NULL and id is a collection, use the token of the source collection. Otherwise, no query is performed to the Facebook Graph API and an empty collection is returned.

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 id. If no value for a given field is found, it will be set to NULL.

n

If id is an iterable collection, then n is the maximum number of conversations to be pulled for each element of the source collection in id. It can be set to Inf to pull out any available conversation and assumes the default value from the value of facebook.maxitems global option if missing. If id is not a collection or cannot be iterated, the parameter is ignored.

metadata

If set to TRUE, the metadata for each ID is pulled with the data and the type slot is fed accordingly. Please note that setting this to TRUE could considerably slow down the execution time, as more queries are needed.

.progress

progress_bar object as defined in the plyr package. By default the none progress bar is used, which prints nothing to the console. See create_progress_bar for details.

stop.condition

anonymous function that is executed for each element of the collection, passed to the function as a list called 'x'. If the function returns TRUE, the execution of the query will end up at the end of the current page (even if more pages of data are available). By default, this function will always return FALSE.

Details

FacebookConversationsCollection is the constructor for the FacebookConversationsCollection-class. It returns data about inbox conversations of users or pages but doesn't return lists of messages or users involved.

A FacebookMessagesCollection-class can be built on top to pull out the messages of each conversation.

Value

A collection of conversations in a FacebookConversationsCollection-class object.

Nesting fields

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).

Valid sources

Instead of a character vector, one of these collections can also be passed as parameter in id:

Author(s)

Gabriele Baldassarre https://gabrielebaldassarre.com

See Also

FacebookMessagesCollection, facebook.participants, facebook.senders

Other Facebook Collection Constructors: FacebookAlbumsCollection, FacebookCommentsCollection, FacebookEventsCollection, FacebookGroupsCollection, FacebookLikesCollection, FacebookMessagesCollection, FacebookPagesCollection, FacebookPhotosCollection, FacebookPostsCollection, FacebookReactionsCollection, FacebookUsersCollection, FacebookVideosCollection

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
## See examples for fbOAuth to know how token was created.
 load("fb_page_oauth")
 
## Getting the conversations of an example page. A page access token is needed to access the inbox
 conversations <- FacebookConversationsCollection(FacebookPagesCollection(
                                                    "9thcirclegames", fb_page_oauth))

## End(Not run)

theclue/facebook.S4 documentation built on May 31, 2019, 9:11 a.m.