skip to Main Content

I am trying to solve the last exercise in the graph academy of facebook developer page, https://developers.facebook.com/graph-academy/graph-api-basics/10/ but when i was asked to:

“GET call using the value from the next field.” i cannot get the excersice well done, because i get a full url in the value for paging.next

my code is:

    // Graph API Basics
    // Lesson 10 - Pagination
    // The FBID of the Facebook page is 20531316728 or facebook.
    FB.api('/facebook/posts', 'GET', {}, function(response) {
      var paging = response.paging;
      log(paging);
      log(paging.next);
    );
    FB.api('/facebook/posts', 'GET', {}, function(response) {   
    });

the last part, FB.api, is my best try, but when i put the value on paging.next is a full url, i have tryied copy the entire url inside the brackets, or replacing responce variable, anyone can give me a hint?

Also i have tried this, it is working on the js sdk console, but it is not the expected result, the green checkmark is not triggered.this is the screenshot

    // Graph API Basics
    // Lesson 10 - Pagination
    // The FBID of the Facebook page is 20531316728 or facebook.
    FB.api('/facebook/posts', 'GET', {}, function(response) {
      var paging = response.paging;
      log(paging);
      log(paging.next);
    );
    FB.api('paging.next', 'GET', {}, function(response) {   
    });

2

Answers


  1. Why your answer won’t work:

     FB.api('paging.next', 'GET', {}, function(response) {   
    });
    

    First of, ‘paging.next’ is just a string. Secondly it is outside the callback function which is outside the callback scope.

    Here’s the way I answered it.

    FB.api('/facebook/posts', 'GET', {}, function(response) {
      var paging = response.paging;
      log(paging.next);
      FB.api(paging.next);  //paging.next object is to be passed to the next api call.
    });
    

    I hope this helps.

    Login or Signup to reply.
  2. They just wanted to log first and second pagination object. Try the code below:

    FB.api('/facebook/posts', 'GET', {}, function(response1) {
        var paging = response1.paging;
        log(paging);
        FB.api(paging.next, '', {}, function(response2) {
            log(response2.paging);
        });
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search