- register on developers.facebook.com
- create an app: choose
Other
->Business
, don't link any "Business portfolio" - 🏁 as soon as you reach
Add products to your app
, the app is ready - open the Graph Explorer
- from the
Meta App
dropdown, select your just-created-app - grant the following permissions:
pages_manage_metadata
,pages_manage_posts
,pages_show_list
- from the
User or Page
dropdown, selectGet Page Access Token
| this will start a wizard to grant access to the page you want to post to - from the
User or Page
dropdown, select your Page - click
Generate Access Token
Submit and you'll get the id
and name
of the Page:
{
"id": "10...45",
"name": "TLI Test Channel"
}
This is a SHORT-LIVED (~2 hours) token. Input it into the Access Token Debugger and click Extend Access Token
. This generates a LONG-LIVED (~2 months) token.
Now go back to the Graph Explorer. From the User or Page
dropdown, select User Token
. Submit and you'll get your own user-id
:
{
"id": "10...99",
"name": "Gianluigi NeverEnough Zanettini"
}
Customize this cURL request and fire it away:
curl -i -X GET "https://graph.facebook.com/v19.0/{user-id}/accounts?access_token={long-lived-access-token}"
This will return a JSON with a access_token
fields. That token should be never-expiring: test it with the Access Token Debugger and you should get:
Expires: Never
Data Access Expires: 1719608325 (in about 3 months)
(don't mind the Data Access Expires
: it's not need just to post)
- copy the variables to your local
.env
file. - assign the never-expiring token (the last one) and page ID values to the variables
You can now post a message on the page with
$messenger->sendMessageToPage($messageText)`
Or share a URL:
$messenger->sendUrlToPage('https://turbolab.it')`