Skip to content

Instantly share code, notes, and snippets.

@michaelkarrer81
Last active February 28, 2024 05:03
Show Gist options
  • Save michaelkarrer81/88fbc36d99a8a32a83f3efe234f7690a to your computer and use it in GitHub Desktop.
Save michaelkarrer81/88fbc36d99a8a32a83f3efe234f7690a to your computer and use it in GitHub Desktop.
[facebook api cheat sheet] Facebook API Cheat Sheet #facebook

Weblinks

Facebook Documentation

1.) Important Preparations!

  • Make sure you have the Facebook Business Manager and your account is an administrator
  • Make sure your Business in the Business Manager is already verified (Security Center > Business Verification > Start Verification)
  • Some of the app access rights require extra contracts to be signed - make sure they are signed! You can check this at: Business Manager > Settings > Business Info > Supplemental Terms Status You may need to finish this step AFTER you requested the access rights for your app!

2.) Create Facebook App with Marketing API Product (and Webhooks if needed)

  1. Create a new Facebook APP on the Webpgage https://developers.facebook.com under the menu My Apps > Create App
    1. Enter the app name e.g.: Amnesty Fundraising Studio Leads Connector and a contact e-mail that you have access too
  2. Open the configuration page of your newly created app (e.g.: https://developers.facebook.com/apps/2322825277821500/dashboard)
    1. Add products to your facebook app
      1. Scroll down on the dashboard and add product "Marketing API" by pressing the button set up
      2. Optional: Add product "Webhooks" if you want real time information about lead updates
  3. Go to the basic app settings https://developers.facebook.com/apps/2322825277821500/settings/basic
    1. Scroll to the bottom and click Select the Platform then choose Website
      1. Set the Website URL for the platform (e.g.: Your Webpage URL)
    2. Optional: Enter personal data of the Data Protetction Officer (GDPR)
  4. Go to the advanced app settings https://developers.facebook.com/apps/2322825277821500/settings/advanced
    1. Select Upgrade API Version 6.0
    2. Set the Business Manager (to connect the new app with the business manager - can be done later in the business manger also)
    3. Optional: Link an Advertising Account to the App (Authorized Ad Account IDs)
    4. Optional: Create an App Page
    5. Optional: Use the Server IP Whitelist if possible for extra security
  5. Change app rights under App Review > Permissions and Features if needed Every change of app permissions will trigger an AppReview
    1. Choose leads_retrival and manage_pages (to be able to create a page access token later on) and press on continue to start the app verification process:
  6. Complete the app verification process (either for your user or link a verified business manager account)
    1. Provide Verification Details
      1. My app dosent have a gui
      2. My app transfer leads information
    2. Requestet Permissions 2. Tell us how u use leads retrival
      1. Import leads to our CRM
      2. Tell us how u use manage_pages
        1. Create a page access token to retrive leads into our CRM
    3. Complete required app settings
      1. Add Privacy Policy URL (Link to your Webpages GDPR page) Settings
      2. Add an Icon
      3. Support my own Business
      4. Select app Category (e.g.: Business and Pages)
    4. Press the button Submit for Review
      1. Accept the Onboarding terms

3.) Generate a never expiring page token based on a system user access token for leads retrival

From the facebook documentation:

If you do not activate and customize the Leads Access manager, by default, only your Page admins are able to access leads information. In addition, by default, CRMs will receive notifications sent by Facebook. If you are comfortable with this default rule, then you do not need to enable this advanced feature.

If these default rules do not meet your needs or you are running lead ads in regions that have specific regulation requirements. We recommend you customize your permission using the Leads Access manager. For example, if you work with an agency who runs your lead ads from your Page and they are assigned a Page admin role, under default rule every employee of the agency that have page admin could access your leads. In this case you can user Leads Access Manager to revoke leads access permission of this agency business.

ATTENTION: !!! There will be no error message on leads import if you activate advanced leads access management but forget to give access to the (system_)user for leads!!! !!! The consequence of this is that we can not no if there are no new leads or if there is a problem in the configuration !!!

This inidcates that we must be the page admin to generate page access tokens. If the custommer do not want to give us page admin rights he has to enable "Custom Leads Access" in his Business Manager under "Integrations > Leads Access" and then add our system user as a role to his page with adervertising rights. It is not clear if we or the custommer must create the page access token if Leads Access by User is enabled in the custommers Business Manager!

Most stuff can be done with the Facebook Business Manager!

  1. Create a new system user in the business manager of type employee
  2. Select the newly created system user and assign assets
    • Assing the app (with Admin Access: Manage App)
    • Assing a page (with *View Page performance)
  3. Generate New Token for the system user Set correct Scopes e.g.: pages_show_list, ads_read, manage_pages, leads_retrival, ads_management
  4. Copy the newly created system user token and paste it in the Facebook Access Token Debuger You shoud see Type: System User, Expires: Never and the previously set Scopes HINT: This is a system user token for our app with the selected scopes
  5. Generate a Page Access Token via the GraphAPI https://graph.facebook.com/<page_id>?fields=access_token&access_token=<system_user_token>

4.) Use the Page Access Token in Fundraising Studio (Online) to setup and start the lead import

  1. Open Fundraising Studio Online and go to "Kanäle > " TODO ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment