mmmoustache
mmmoustache

Reputation: 2323

Facebook Insights API - Retrieve data without being logged in

I'm trying to programmatically fetch Insights data from the Facebook Pages that I am the admin of. Using the access token generated by the Graph API explorer, I can access the insights data for every page no problem.

However, this only works if I'm logged into Facebook; otherwise I receive the message "Error validating access token: The session is invalid because the user logged out". Is there a way to access this data without being logged in? Should I log myself in using the Javascript SDK before every API call?

Is there a better way than this to retrieve insight data from the pages that I manage?

Upvotes: 0

Views: 656

Answers (1)

andyrandy
andyrandy

Reputation: 74004

You should use a Page Token to access Insights data from Facebook Pages. An Extended Page Token is valid forever, you just need to store it on your server for future usage.

Basically, you just need to extend the User Token and request a Page Token with that Extended User Token with /me/accounts.

Here are some links explaining how to generate an Extended Page Token:

Upvotes: 1

Related Questions