Wrapper functions around the Facebook Marketing 'API' to create, read, update and delete custom audiences, images, campaigns, ad sets, ads and related content.
This R package includes wrapper functions around the Facebook Marketing API to create, read, update and delete custom audiences, images, campaigns, adsets, ads and related content.
To be able to use this package, you will have to create a Facebook App and authorize it to mange your Facebook ads. Basic steps to create an app with Development access level letting you manage up to 5 Facebook ad accounts:
Create new application at https://developers.facebook.com/apps with "basic setup".
Fill in a unique
Display Name (eg "app_testing_foobar_42"), set the category to eg "Business". Click on "Create App ID" & pass the captcha test.
In "Settings/Basic", click "Add Platform" add create "Website" platform with the URL of http://localhost:1410/ and "localhost" as the "App Domain". Click "Save Changes".
In the "Settings/Advanced" tab, add http://localhost:1410/ as the "Valid OAuth redirect URIs". Click "Save Changes".
Note your "App ID" and "App Secret" on your dashboard, and use those in the below R script to get a token for future authentication:
library(httr)app <- oauth_app('facebook', 'your app id', 'your app secret')Sys.setenv('HTTR_SERVER_PORT' = '1410/')tkn <- oauth2.0_token(oauth_endpoints('facebook'), app, scope = 'ads_management',type = 'application/x-www-form-urlencoded', cache = FALSE)tkn <- tkn$credentials$access_token
Please note the above last step: we store the token as a string. Now you can save that token in a safe place and start using
fbad_init(accountid = accountid, token = tkn, version = '2.5')
And list all your ads along with the ad name and status or eg filter for the active ads:
fbad_list_ad(fields = c('name', 'effective_status'))fbad_list_ad(statuses = 'ACTIVE', fields = 'name')
This package makes your life more convenient when it comes to interacting with the Facebook Marketing API, but unfortunately, it cannot save you the time to get familiar with the actual API. To be able to interact with Facebook, you have to learn about how the API works etc -- see the documentation at https://developers.facebook.com/docs/marketing-apis
Documentation cleanup and first CRAN release with support for Facebook Marketing API v2.4 and v2.5.
Internal CARD.com R scripts were published publicicly as an open-source R package after Facebook made it's Marketing API generally available at the F8 2015 conference in March 2015.
Supported API versions in the development verison of the package hosted on GitHub at https://github.com/cardcorp/fbRads: