简体   繁体   中英

Empty data response from Facebook API, using app access token

Code that I had written to fetch a Facebook page's posts using an app access token has suddenly stopped working. The JSON response's data object is an empty array. I'm not getting any error messages. When I try making the same request using an access token generated by the Graph API explorer, I get back a valid JSON response containing data. I've tried resetting my app's secret and generating a new access token, but I still get back an empty data object.

When I use the Facebook access token debugger, the only information returned is the App ID.

I generated my app access token by making a GET request to https://graph.facebook.com/oauth/access_token?client_id=<app_id>&client_secret=<app_secret>&grant_type=client_credentials

I don't have control over the page I'm trying to fetch data from, but I can contact the admin. Are there any permissions I should have them check?

Without any error messages or feedback, I'm at a loss on how to debug this. Does anyone have any advice?

This works perfectly.

Demo

token = 'valid_access_token';
page = '20531316728';
url = 'https://graph.facebook.com/'+page+'/feed?access_token="+token+"&fields=id,message&limit=10';
    comments = [];
$.ajax({
    'async': false,
    'url': url,
    'dataType': "json",
    'success': function (data) {
      $('.result').html(JSON.stringify(data));
    },
    'error': function(data){
      $('.result').html(JSON.stringify(data));
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM