Search code examples
facebookfacebook-graph-apiaccess-tokeninsight

Get application insight data with applicaiton ID and secret


So in order to get the insight data for my application I need the access_token with read_insight_data permission. However I don't want a user interaction during the process. Can I get my application's insight data with just application ID and secret?

thanks, Green


Solution

  • Okay I got it.

    First, get client(AKA application) access token:

    https://graph.facebook.com/oauth/access_token?client_id=${client_id}&client_secret=${client_secret}&grant_type=client_credentials
    

    facebook will return something looks like:

    access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    

    Second Use that returned token you can get the application insight data:

    https://graph.facebook.com/${client_id}/insights/?access_token=XXXXXXXXXXXXXXXXXXXXXXXXX