How does paging in facebook javascript API work?

前端 未结 5 1817
粉色の甜心
粉色の甜心 2020-11-29 19:45

I\'m trying to recover the last week posts in my facebook news feed with the javascript sdk. I\'m able to get the first page but then, I don\'t know how to continue iteratin

5条回答
  •  难免孤独
    2020-11-29 20:32

    If you simply wanted to get the next page (using the paging.next object) you could do a jQuery.getJSON request. Something like the following:

    function loadAlbums(){
        FB.api('/me/albums', function(response){
            handleAlbumsResponse(response);
        });
    }
    
    function handleAlbumsResponse(response){
        var albums = response.data;
    
        for( var i in albums){
            var album = albums[i];
            $('#albums ul').append('
  • ' + album.name + '
  • '); } if( response.paging.next){ console.log('fetching next page...'); $.getJSON(response.paging.next, function(response){ handleAlbumsResponse(response); }); } }

提交回复
热议问题