- Prerequisities
- Introduction
- Basic Config
- Advanced Config
- How to get a Permanent Facebook Page Access Token
This guide assumes
- You are familiar with JSON formatting
- You have read and understood the Alarm Configuration Wiki
- You are comfortable with the layout of
alarms.json
.
Please familiarize yourself with all of the above before proceeding.
Facebook Pages is an online social networking service that enables users to post status messages to a public profile specifically created for business, brands, celebrities, causes, and other organizations. Registered users can read and post messages, but those who are unregistered can only read them. Users access Facebook through the website interface, SMS or mobile device app.
PokeAlarm offers the following for Facebook Pages:
- Personalized notifications via Dynamic Text Substitution
These alarms.json
parameters - active
, type
, and page_access_token
- are required to enable the Facebook Pages alarm service:
Parameters | Description |
---|---|
type | must be facebook_page |
active | True for alarm to be active |
page_access_token | Your permanent FB page access token |
{
"active": "True",
"type":"facebook_page",
"page_access_token":"YOUR_PAGE_ACCESS_TOKEN"
}
Note: The above code is to be inserted into the alarms section of alarms.json. It does not represent the entire alarms.json file.
In addition to the 3 required parameters, several optional parameters are available to personalize your Facebook Pages notifications. Below is an example of these optional parameters and how they are incorporated into a functional alarm layout for Facebook Pages.
These optional parameters are entered at the same level as "type":"facebookpages"
.
Parameters | Description | Default |
---|---|---|
startup_message |
confirmation post when PokeAlarm initialized | True |
These optional parameters below are applicable to the pokemon
, pokestop
, gym
, egg
, and raid
sections of the JSON file.
Check Image column to see where everything appears in the final publication.
Parameters | Description | Image |
---|---|---|
message |
Message to post as status message | 1 |
link |
Link to be added to notification text | Link |
image |
Url of the image to show as a preview (empty for linked page preview) | 2 |
name |
Link title (empty for linked page title) | 3 |
description |
Link description (empty for blank description) | 4 |
caption |
Link domain (empty for linked page domain) | 5 |
When it says "empty for X"
it means that you can disable the default PokeAlarm value setting that parameter to ""
in your alarms.js
file. In that case Facebook will use the link information to fill that field in the publication.
For example if you have link
as a google maps link and you disable the image
parameter setting it to ""
, it will be a minimap image of that coordinates.
pokemon
default values:
Parameters | Default |
---|---|
message |
A wild <pkmn> has appeared! |
link |
<gmaps> |
image |
https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<pkmn_id>.png |
name |
<pkmn> |
description |
Available until <24h_time> (<time_left>) |
caption |
None |
pokestop
default values:
Parameters | Default |
---|---|
message |
Someone has placed a lure on a Pokestop! |
link |
<gmaps> |
image |
https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/pokestop.png |
name |
Lured Pokestop |
description |
Lure will expire at <24h_time> (<time_left>) |
caption |
None |
gym
default values:
Parameters | Default |
---|---|
message |
A Team <old_team> gym has fallen! |
link |
<gmaps> |
image |
https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/gym_<team_id>.png |
name |
<old_team> gym fallen |
description |
It is now controlled by <new_team> |
caption |
None |
egg
default values:
Parameters | Default |
---|---|
message |
A level <raid_level> raid is upcoming! |
image |
https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/egg_<raid_level>.png |
link |
<gmaps> |
name |
Egg |
description |
The egg will hatch <begin_24h_time> (<begin_time_left>). |
caption |
None |
raid
default values:
Parameters | Default |
---|---|
message |
A Raid is available against <pkmn>! |
image |
https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<pkmn_id>.png |
link |
<gmaps> |
name |
Raid |
description |
The raid is available until <24h_time> (<time_left>). |
caption |
None |
{
"active": "True",
"type":"facebook_page",
"page_access_token":"YOUR_PAGE_ACCESS_TOKEN",
"startup_message":"True",
"pokemon":{
"message": "<pkmn> available. <move_1>/<move_2> (<iv>% - <atk>/<def>/<sta>)",
"link": "<gmaps>",
"image" : "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<pkmn_id>.png",
"description": "Address: <address>",
"name": "<pkmn>"
},
"pokestop":{
"message": "Someone has placed a lure on a Pokestop! Lure will expire at <24h_time> (<time_left>).",
"description": "Address: <address>",
"link": "<gmaps>",
"name": ""
},
"gym":{
"message":"A Team <old_team> gym has fallen! It is now controlled by <new_team>.",
"link": "<gmaps>",
"name": "<new_team>",
"description": "Address: <address>",
"image": ""
},
"egg": {
"message": "A level <raid_level> raid is upcoming!",
"image": "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/egg_<raid_level>.png",
"link": "<gmaps>",
"name": "Egg",
"description": "The egg will hatch <begin_24h_time> (<begin_time_left>)."
},
"raid": {
"message": "A Raid is available against <pkmn>!",
"image": "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<pkmn_id>.png",
"link": "<gmaps>",
"name": "Raid",
"description": "The raid is available until <24h_time> (<time_left>)."
}
}
Note: The above code is to be inserted into the alarms section of alarms.json. It does not represent the entire alarms.json file.
Use the Graph API Explorer for all of these steps except where otherwise stated.
If you already have an app, skip to step 1.
- Go to My Apps.
- Click "+ Add a New App".
- Setup a website app.
- Go to App Review of your new app and make sure your app is made Public.
- Go to the Graph API Explorer.
- Select the application you want to get the access token for by clicking on the "Graph API Explorer" dropdown near the top right.
- Click "Get Token" dropdown and choose "Get User Access Token".
- In the pop-up, under the "Events, Groups & Pages" section, check "manage_pages" and "publish_pages".
- Click "Get Access Token".
- Grant access from a Facebook account that has access to manage the target page. Note that if this user loses access the final, never-expiring access token will likely stop working.
Token that appears in the "Access Token" field is your short-lived access token.
Following these instructions from the Facebook docs, make a GET request to
https://graph.facebook.com/v2.2/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={short_lived_token}
entering in your app's ID and secret, generated from step 0, and the short-lived token, generated in the previous step. Be sure to remove the curly braces "{}" when replacing values.
You cannot use the Graph API Explorer. For some reason it gets stuck on this request. I think it's because the response isn't JSON, but a query string. Since it's a GET request, you can just go to the URL in your browser.
The response should look like this:
access_token=ABC123&expires=5182959
"ABC123" will be your long-lived access token. You can put it into the Access Token Debugger to verify. Under "Expires" it should have something like "2 months".
Using the long-lived access token, make a GET request to
https://graph.facebook.com/v2.2/me?access_token={long_lived_access_token}
Be sure to remove the curly braces "{}" when replacing values. The id field is your account ID. You'll need it for the next step.
Make a GET request to
https://graph.facebook.com/v2.2/{account_id}/accounts?access_token={long_lived_access_token}
Be sure to remove the curly braces "{}" when replacing values. The JSON response should have a data field under which is an array of items the user has access to. Find the item for the page you want the permanent access token from. The access_token field should have your permanent access token. Copy it and test it in the Access Token Debugger. Under "Expires" it should say "Never".