Create a csv with the statistics of a group, page or the user's timeline.
- Download the binary and unzip it.
- Build the binary yourself:
git clone https://github.com/BraisGabin/facebook-stats.git
cd facebook-stats
gradle distZip
The binary is generated at build/distributions/
facebook-stats <output_file_path> <fb_user_id_group_id_or_page_id> <fb_access_token> [max_posts]
Where:
output_file_path
is the name that you want for the csv file generated.fb_user_id_group_id_or_page_id
is the id of the user, group or page that you want to get the stats. It's allways a long number. How can I know that id?.fb_access_token
is the Facebook access token that the script is going to use to get access to the information. How can I get that?.- If you want the stats for a user the access token must have the
read_stream
permission. - If you want the stats for a close or private group the access token must have the
user_groups
permission.
There is not a cannonical way to find a Facebook id. I'm going to list 3 different ways from easier to harder.
- Go to the user, group or page timeline and look at the url in your browser. If it's the way:
https://www.facebook.com/19292868552
the number19292868552
is the id that you are looking for. - If the url is different you can use the page: Lookup-ID.com. Paste the url in that web and it'll show you the id that you are looking for.
- If Lookup-ID.com doesn't show you the id you can find it yourself:
- At the page click with the left botton of your mouse and select
Show source code
. - It'll appear a page with the HTML of the page. Press Ctrl + F (cmd + F in Mac OS X) to open the find tool.
- Find for
profile_id=
,group_id=
orpage_id=
. The option depends on the type of id you are looking for. - The id is going to be just after that text.
There are different ways to get an access token but one of the easiest ones is using the Graph API Explorer:
- Go to the Graph API Explorer page.
- Click at
Get Token > Get Access
, - Click the permissions you want to grant, remember:
- If you want the stats for a user the access token must have the
read_stream
permission. - If you want the stats for a close or private group the access token must have the
user_managed_groups
permission and you must be admin.
- Click at
Get Access Token
. - Copy the Access Token that appears at the top of the page. It's a very long with lettera and numbers.