Table of contents
- Screenshots e links.
- Intro:
- Steps to create the app :
- Token interlude :
- Steps to get app id, app secrets:
- Steps to get app tokens, user acccess tokens, page access tokens:
- Steps to set the Permissions:
- Step-by-Step Guide: Make a Test API Call for app001p0001 in Facebook Graph API Explorer.
- Test pages_read_engagement
- Test pages_read_user_content
- Test pages_manage_posts
- Test pages_show_list
- Test pages_manage_metadata
- Facebook Login for Business
- 🚀 Steps to Get pages_read_engagement, pages_manage_posts, and pages_show_list Working
- ✅ 1. Upgrade to Advanced Access
- ✅ 2. Generate a User Access Token with Correct Permissions
- ✅ 3. Exchange for Long-Term User Token
- ✅ 4. Get the Page Access Token
- ✅ 5. Use the Page Access Token for API Calls
- Final Notes
- Verifica dell'accesso
Screenshots e links.
Sensible data like app id are hidden
https://github.com/kenny1323/facebook_graph_api_002/blob/main/00.screencapture-developers-facebook-apps-creation-2025-02-18-00_48_29.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/01.screencapture-developers-facebook-apps-creation-2025-02-16-20_43_17.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/02.screencapture-developers-facebook-apps-id-xxx-settings-basic-2025-02-16-20_58_48.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/03.screencapture-developers-facebook-apps-id-xxx--settings-advanced-2025-02-16-20_59_35.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/04.screencapture-developers-facebook-apps-id-xxx--review-tab01-2025-02-16-20_59_35.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/05.screencapture-developers-facebook-apps-485986667895551-app-review-permissions-2025-02-16-21_50_12.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/06.screencapture-developers-facebook-apps-id-xxx-app-review-permissions-2025-02-17-18_47_08.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/15.screencapture-developers-facebook-apps-1394411334874449-settings-basic-2025-02-19-16_41_16.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/17.screencapture-developers-facebook-apps-1394411334874449-settings-basic-2025-02-19-16_41_52.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/18.screencapture-developers-facebook-apps-1394411334874449-settings-basic-2025-02-19-16_43_55.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/19.screencapture-developers-facebook-apps-1394411334874449-settings-basic-2025-02-19-16_44_34.png
https://github.com/kenny1323/facebook_graph_api_002/blob/main/20.screencapture-developers-facebook-apps-1394411334874449-settings-basic-2025-02-19-17_05_30.png
https://developers.facebook.com/apps/
https://github.com/kenny1323/facebook_graph_api_002/blob/main/Guide_%20Build%20a%20Facebook%20App%20for%20Content%20Retrieval.pdf
Intro:
Below there are the steps to:
create the facebook app;
set up permission to fetch posts, photos, and albums from your Facebook Page.
Your starting point is the link https://developers.facebook.com/apps/creation/
and the screenshot 00 and 01, these help you to during the Facebook App creation process.
Steps to create the app :
Create facebbok account and login.
Visit
Look screenshot 00 and 01,
Fill fields:
app name ;
email ;
Click Next to proceed.
Select "Other" (at the bottom of the list).
This option allows you to manually choose Page-related permissions later.
Click Next to proceed.
Select App Type:
- Choose Consumer .
Finalize App Setup:
Enter your App Name and Contact Email.
Click Create App.
Now the facebook app is created.
Below there are the steps to:
get some info like app id ;
set up permission to fetch photos etc, which is your main purpose.
Token interlude :
Before to talk about Steps to get app id etc, make some clarificaion.
Your purpose is to download posts and photos from a Facebook page via the Graph API, as the page administrator, you need the following:
1. Tokens and Credentials You Need
This are fake data, customize them
App ID:
48777777777777771
(your app’s ID).App Secret:
73b6s6weh36e36dr6
(your app’s secret).User Access Token: A token with the
manage_pages
andpages_read_engagement
permissions.Page Access Token: A token for the specific page you want to access.
2. Why You Need These Tokens
App ID and App Secret: These are required to authenticate your app and generate tokens.
User Access Token: This token allows you to access the pages you manage and request a Page Access Token.
Page Access Token: This token is specific to the page and allows you to interact with its content (e.g., download posts and photos).
3. App Type: Business or Consumer?
Simplest Solution: Use a Consumer app.
A Consumer app is easier to set up and manage for personal or small-scale use.
A Business app is more complex and is typically used for large-scale integrations or business purposes, and probably require business veriication,
like tax id, etc..
Steps to get app id, app secrets:
See screenshot 02 and 03.
You can see your app id, say
48777777777777771
.Now visit "App Settings"
https://developers.facebook.com/apps/
48777777777777771
/settings/Choose the Correct Tab
Choose the
Basic
tab.This tab contains the App ID, App Secret, Contact Email, and Privacy Policy URL, which are essential for API authentication and approval.
Fields to set up in the
app setting/basic
TabApp ID → Needed for API authentication.
App Secret → Used for secure API requests (keep it private).
Say your app secret is
73b6s6weh36e36dr6
, as fake example.Contact Email → Required for Facebook verification.
Privacy Policy URL → Add a valid URL for Facebook API approval.
for privacy etc, use this generator
Terms of Service URL (optional but recommended).
Business Verification → Start this process if needed for advanced API access.
Click save.
Fields to Select in the
app setting/Advanced
TabProceed to Advanced settings only if you need extra security (e.g., IP restrictions).
Visit again
https://developers.facebook.com/apps/
48777777777777771
/settings/advanced/on top click live app
visit
https://developers.facebook.com/apps/
48777777777777771
/settings/basic/#verification-cardcreate a simple company profile say Business001.
Click finish and verifye later.Wait 5-10 minutes.
See screenshots 15 17 18 19 20
Steps to get app tokens, user acccess tokens, page access tokens:
Step 1: Open Graph API Explorer via browser
Go to Facebook Graph API Explorer
Select your App Name → app001 from the top-left dropdown.
Ensure you are logged in with the Admin account that manages the Page.
Select app token.
In this case say you get fake app token : "H&hnH6HG6gHT"
In https://developers.facebook.com/tools/explorer/
select user token, this works for short term
exchange a short-lived User Access Token for a long-lived User Access Token in Facebook's Graph API.
curl -X GET "https://graph.facebook.com/v22.0/oauth/access_token?grant_type=fb_exchange_token&client_id=4847777777775614&client_secret= 73b6c3ecbcd6eac5c275b93e071abca1&fb_exchange_token=EAAG4mmSZBag4BO4xVQJfffffffffffffffffffffffffffffffffffffffffffff9uKOtrsOTRKMSQhhZBu50tJqnN7fXRJdBu mRk0EYeyd8AU0DFm4BijS6nBgBVldi4p6ONjvrLujUZC4SW2SvqpL5sp4DZA8tZCesfYSR98EffffffffffffffffffffffffffffffffffffffffffffggvvTw9pkLCBvydvUgS1uGZAaOf6S4zAlux6 kjOuzzDpigZDZD"
Create page
Get page access token
curl -G "https://graph.facebook.com/v22.0/me/accounts" -d "access_token=EAAG4mmSZBag4BO2mUEDDZBDuaKRcANYPXdj1Avjulp3D0G
SxA86spBiuaZBBpbW21z5XArSPAASAnLCXEe1GxV8pdZAyvSrHUCVPD6E0K8oQ39QeLZCGv5mcgSF5TFM3YI6ZCi5ZBcdFsRSF1COj4ZCZCJFy9uqNuhKkEFCTwr8D8ycRSTkPtxSXs0ux5qxAnTjnM"
Step 1 alternaive: Open Graph API Explorer via shell
Go to Facebook Graph API Explorer
Select your App Name → app001 from the top-left dropdown.
Ensure you are logged in with the Admin account that manages the Page.
To get app token via shell , run bash command.
In this case you get:
fake app token : "H&hnH6HG6gHT"
user001@debian:/tmp$ curl -G "https://graph.facebook.com/oauth/access_token" --data-urlencode "client_id=48777777777777771" --data-urlencode "client_secret=73b6s6weh36e36dr6" --data-urlencode "grant_type=client_credentials" {"access_token":"48777777777777771|H&hnH6HG6gHT","token_type":"bearer"} user001@debian:/tmp$
In https://developers.facebook.com/tools/explorer/
select user token, this works for short term
We still get user access token via browser,
because the shell way to get it requieres another code, the authorization code,
but to get the authorization code we require the browser.
So , in this case it is just an over complication.
Exchange a short-lived User Access Token for a long-lived User Access Token in Facebook's Graph API.
curl -X GET "https://graph.facebook.com/v22.0/oauth/access_token?grant_type=fb_exchange_token&client_id=4847777777775614&client_secret= 73b6c3ecbcd6eac5c275b93e071abca1&fb_exchange_token=EAAG4mmSZBag4BO4xVQJfffffffffffffffffffffffffffffffffffffffffffff9uKOtrsOTRKMSQhhZBu50tJqnN7fXRJdBu mRk0EYeyd8AU0DFm4BijS6nBgBVldi4p6ONjvrLujUZC4SW2SvqpL5sp4DZA8tZCesfYSR98EffffffffffffffffffffffffffffffffffffffffffffggvvTw9pkLCBvydvUgS1uGZAaOf6S4zAlux6 kjOuzzDpigZDZD"
Create page
Get page access token
curl -G "https://graph.facebook.com/v22.0/me/accounts" -d "access_token=EAAG4mmSZBag4BO2mUEDDZBDuaKRcANYPXdj1Avjulp3D0G
SxA86spBiuaZBBpbW21z5XArSPAASAnLCXEe1GxV8pdZAyvSrHUCVPD6E0K8oQ39QeLZCGv5mcgSF5TFM3YI6ZCi5ZBcdFsRSF1COj4ZCZCJFy9uqNuhKkEFCTwr8D8ycRSTkPtxSXs0ux5qxAnTjnM"
Steps to set the Permissions:
See screenshot 04, 05, 06.
Go to "App Review" → "Permissions & Features":
https://developers.facebook.com/apps/
48777777777777771
/app-review/permissions/We would request the following permissions.
For short , we call them app001p0001.
pages_read_engagement
(View posts, comments, and reactions)pages_read_user_content
(Read Page posts and comments)pages_manage_posts
(Create and manage posts)pages_show_list
(View a list of the Pages you manage)pages_manage_metadata
(Access Page insights)
Permissions in "App Review" → "Permissions & Features"
are categorized as either:
Available immediately (without a test API call)
Require a test API call before requesting advanced access
So, in particular, some of the permissions app001p0001 can be enabled without making a "test API call."
Permissions You Can Enable Without a Test API Call .
✅ pages_show_list – View a list of the Pages you manage.
On the other side , some of the permissions app001p0001 can be enabled just after you make a "test API call."
Permissions That Require a Test API Call.
⚠️ pages_read_engagement – View posts, comments, and reactions.
⚠️ pages_read_user_content – Read Page posts and comments.
⚠️ pages_manage_posts – Create and manage posts.
⚠️ pages_manage_metadata – Access Page insights.Below a step-by-step guide on how to make the test API call!
Step-by-Step Guide: Make a Test API Call for app001p0001
in Facebook Graph API Explorer.
Remember :
the app name is app001.
the list of permission we wanna enable is named app001p0001, which stand for app001 permission0001 .
since some permissions require a test API call before you can request advanced access, follow these steps to complete the test for
app001p0001
.
Step 2: Generate a Test User Access Token
Click "Get Token" → "Get User Access Token".
In the pop-up, enable the following permissions from
app001p0001
:pages_read_engagement
pages_read_user_content
pages_manage_posts
pages_show_list
pages_manage_metadata
Click Continue, grant the requested permissions, and copy the generated token.
Step 3: Make Test API Calls
You now need to test each permission by making API requests.
Test pages_read_engagement
Fetch page posts, comments, and reactions:
GET /{page-id}/feed?fields=message,comments,likes.summary(true)&access_token=YOUR_USER_ACCESS_TOKEN
Test pages_read_user_content
Fetch user-generated posts and comments:
GET /{page-id}/published_posts?fields=message,comments&access_token=YOUR_USER_ACCESS_TOKEN
Test pages_manage_posts
Create a test post on your page:
POST /{page-id}/feed Params: message=Test API Post access_token=YOUR_USER_ACCESS_TOKEN
Test pages_show_list
Get a list of Pages you manage:
GET /me/accounts?access_token=YOUR_USER_ACCESS_TOKEN
Test pages_manage_metadata
Fetch page insights:
GET /{page-id}/insights?metric=page_impressions,page_engaged_users&access_token=YOUR_USER_ACCESS_TOKEN
Step 4: Validate the API Response
If the response returns data successfully, you have successfully tested the permission.
If you receive an error (e.g.,
(#10) This permission requires approval
), double-check:You granted the correct permissions in Step 2.
You are using the correct page ID.
The access token is valid.
Step 5: Submit for Advanced Access
Go to Facebook App Review.
Click "App Review" → "Permissions & Features".
Find each permission in
app001p0001
and click "Request Advanced Access".Facebook may ask for a justification—you can explain that your app fetches posts, photos, and comments for admin-managed pages.
Final Step: Generate a Permanent Page Access Token
Once permissions are approved, generate a long-lived Page Access Token:
GET /me/accounts?access_token=YOUR_USER_ACCESS_TOKEN
Use the access_token
from the Page response for future API calls.
🚀 Now your app001 is set up to fetch posts, photos, and insights with app001p0001
!
Facebook Login for Business
https://developers.facebook.com/docs/facebook-login/facebook-login-for-business/
Facebook Login for Business richiede l'accesso avanzato
La tua app ha un accesso standard a public_profile. Per usare Facebook Login for Business, passa all'accesso avanzato per public_profile.Get Advanced Access
https://developers.facebook.com/apps/980923827310138/business-login/settings/?business_id=1655630395053532
🚀 Steps to Get pages_read_engagement
, pages_manage_posts
, and pages_show_list
Working
Your app already has standard access to the required permissions, but Facebook Login for Business requires advanced access. You need to upgrade public_profile
to Advanced Access and ensure your user token includes these permissions when authenticating.
✅ 1. Upgrade to Advanced Access
Go to Facebook Developer Console → Your App.
Navigate to App Review → Permissions and Features.
Search for public_profile.
Click Get Advanced Access and complete any required verifications.
see screenshot 26 27 28 29
✅ 2. Generate a User Access Token with Correct Permissions
Use the OAuth Authorization URL to manually get a user token.
📌 Run this URL in your browser:
https://www.facebook.com/v22.0/dialog/oauth?
client_id=980923827310138
&redirect_uri=https://example.com/callback
&scope=public_profile,pages_read_engagement,pages_manage_posts,pages_show_list
&response_type=token
Replace
https://example.com/callback
with a valid redirect URL configured in your app settings.Login and accept all requested permissions.
After login, the URL in your browser will contain the User Access Token, copy it.
✅ 3. Exchange for Long-Term User Token
Run this command with your User Access Token:
curl -X GET "https://graph.facebook.com/v22.0/oauth/access_token?grant_type=fb_exchange_token&client_id=980923827310138&client_secret=YOUR_APP_SECRET&fb_exchange_token=YOUR_USER_ACCESS_TOKEN"
🔹 This will return a Long-Term User Token.
✅ 4. Get the Page Access Token
Run this command with your Long-Term User Token:
curl -X GET "https://graph.facebook.com/v22.0/me/accounts?access_token=LONG_TERM_USER_ACCESS_TOKEN"
🔹 This will return a JSON response with page access tokens.
✅ 5. Use the Page Access Token for API Calls
Once you have the Page Access Token, you can make API calls like this:
curl -X POST "https://graph.facebook.com/v22.0/PAGE_ID/feed?message=Hello, World!&access_token=PAGE_ACCESS_TOKEN"
Final Notes
If you get "Invalid Scopes", make sure your app is in Live Mode and has the correct permissions.
Ensure that the user granting permissions is an admin of the Page.
🚀 Try these steps and let me know if you need help!
Documenti
Verifica dell'accesso
Per assicurarti che solo le aziende con un caso d'uso legittimo possano accedere ai dati di un'altra azienda, alcuni endpoint API eseguono un controllo di verifica quando chiamati da un'app creata o reclamata da un'azienda o da un'app business che deve ancora essere collegata a un'azienda. Se l'azienda che ha creato o reclamato l'app o a cui è stata collegata è stata verificata come fornitore di soluzioni tecnologiche, gli endpoint elaboreranno la richiesta normalmente. Se l'azienda non è stata verificata come fornitore di soluzioni tecnologiche, tuttavia, gli endpoint rifiuteranno la chiamata e restituiranno un errore.
La verifica dell'accesso è la procedura che utilizziamo per determinare se un'azienda opera come fornitore di soluzioni tecnologiche.
Quali aziende richiedono la verifica dell'accesso?
Qualsiasi azienda che abbia creato o reclamato un'app che verrà utilizzata da altre aziende e richiede una delle autorizzazioni elencate di seguito deve essere verificata come fornitore di soluzioni tecnologiche prima che altre aziende possano utilizzare l'app.
La verifica dell'accesso è indipendente dall'analisi dell'app e dai livelli di accesso delle autorizzazioni.
Autorizzazioni
Controllo di verifica
Quando un'app reclamata da un'azienda chiama un endpoint che richiede una delle autorizzazioni elencate in precedenza, l'endpoint verifica prima se la persona che ha concesso l'autorizzazione ricopre un ruolo nell'app stessa. Se la persona ricopre un ruolo sull'app, l'endpoint accetta la chiamata e continua l'elaborazione della richiesta.
Se la persona non ricopre un ruolo sull'app, tuttavia, l'endpoint controlla se l'azienda che ha reclamato l'app è stata verificata come fornitore di soluzioni tecnologiche. Se l'azienda è stata verificata come fornitore di soluzioni tecnologiche, l'endpoint elabora la richiesta normalmente, in caso contrario, rifiuta la chiamata e restituisce il seguente errore:
Codice di errore:
100
Descrizione:
Unsupported get request. Object with ID
<OBJECT_ID>does not exist, cannot be loaded due to missing permissions, or does not support this operation.
Per maggiori informazioni sui codici di errore, consulta la documentazione sui Codici di errore dell'API Marketing.
Il controllo di verifica viene eseguito sull'azienda che ha reclamato l'app, ma viene attivato solo quando un'app reclamata chiama un endpoint che ha implementato il controllo di verifica. Ciò significa, che dopo che un'azienda è stata verificata come fornitore di soluzioni tecnologiche, tutte le app che reclama supereranno il controllo di verifica.
Modalità di completamento della verifica dell'accesso
Gli amministratori strumenti business di un'azienda fornitore di soluzioni tecnologiche non verificata che reclama una nuova app riceveranno una notifica e-mail relativa al requisito di verifica dell'accesso ogni volta che un amministratore dell'app richiede l'accesso avanzato per una delle autorizzazioni elencate in precedenza.
L'e-mail includerà un link al modulo per la verifica, ma è possibile accedervi anche dalla Dashboard gestione app accedendo alla scheda Informazioni di base > Verifiche > Verifica dell'accesso.
Per completare la verifica, qualsiasi persona che dispone dell'accesso come amministratore per l'azienda deve classificare e descrivere il modo in cui l'azienda utilizza i dati di altre azienda per fornire loro un servizio.
Dopo che un amministratore strumenti business avrà completato la procedura, verrà presa una decisione entro circa 5 giorni.
Se l'azienda viene verificata come fornitore di soluzioni tecnologiche, gli amministratori strumenti business riceveranno un'e-mail di conferma e gli amministratori dell'app riceveranno un avviso di conferma per gli sviluppatori. Le aziende verificate non dovranno eseguire nuovamente la verifica, tuttavia, in determinate condizioni, un'azienda potrebbe temporaneamente perdere il proprio stato verificato.
Se la verifica come fornitore di soluzioni tecnologiche dell'azienda viene rifiutata, gli amministratori strumenti business riceveranno un'e-mail di rifiuto, gli amministratori dell'app riceveranno un avviso di rifiuto per gli sviluppatori e tutte le chiamate agli endpoint che richiedono le autorizzazioni precedenti avranno esito negativo se l'utente dell'app non ricopre un ruolo nell'app chiamante.
Se cambia il caso d'uso delle aziende rifiutate, un amministratore strumenti business può completare nuovamente la procedura affinché l'azienda venga nuovamente esaminata.
Prerequisiti
Prima che un amministratore strumenti business possa iniziare la procedura di verifica dell'accesso:
Un amministratore strumenti business deve completare la verifica dell'azienda.
Non devono essere presenti restrizioni sull'account business.
Azienda esistente
Agli amministratori strumenti business che hanno già reclamato app utilizzate da altre aziende e richiedono una delle autorizzazioni precedenti verrà inviata automaticamente un'e-mail in merito al requisito di verifica dell'accesso. Gli amministratori dell'app riceveranno anche un avviso per gli sviluppatori su questo requisito.
Dopo aver inviato l'e-mail, gli amministratori strumenti business avranno 60 giorni di tempo per il completamento della procedura di verifica. Se la procedura non viene completata entro 60 giorni, tutte le chiamate agli endpoint che richiedono una delle autorizzazioni precedenti saranno gradualmente soggette ai controlli di verifica.
Perdita dello stato verificato
Un'azienda che è stata verificata come fornitore di soluzioni tecnologiche verrà considerata non verificata in presenza delle seguenti condizioni:
Lo stato di verifica dell'azienda cambia in non verificato.
L'app viene scollegata dall'azienda che l'ha creata o reclamata.
L'account business viene limitato.
Rimosse queste condizioni, l'azienda verrà automaticamente considerata di nuovo un fornitore di soluzioni tecnologiche verificato.