My ionic view uses infinite scroll for friends view and here is the controller:
$scope.friends = [];
$scope.after = "";
var getFriends = function(after)
{
var friends = $q.defer();
UserService.getUser().then(function (d) {
var url = '/me?fields=taggable_friends&access_token='+ d.authResponse.accessToken;
if (after != "")
{
url += "&limit=25&after="+after;
}
facebookConnectPlugin.api(url, null,
function (response) {
console.log(response);
friends.resolve(response);
},
function (response) {
console.log(response);
friends.reject(response);
}
);
});
return friends.promise;
};
$scope.loadMoreData = function()
{
getFriends($scope.after).then(function(d)
{
$scope.friends = $scope.friends.concat(d.taggable_friends.data);
$scope.after = d.taggable_friends.paging.cursors.after;
$scope.$broadcast('scroll.infiniteScrollComplete');
});
};
The first call is executed to url: "/me?fields=taggable_friends&access_token=myAccessToken" and I receive an object as follows:
object
{
id: "string"
taggable_friends
{
data
{
[n]objects
}
paging
{
cursors
{
after: "string"
before: "string"
}
next: "string"
}
}
}
The second call url is: /me?fields=taggable_friends&access_token=myAccessToken&after=QWFKVko1NlJmWUREajBTeERZAbmFJUzlLUWp5ZA3o5cDA5SWVHc1BKblJ6ODMweDd4TzdxMlJyOTdKNDlUb0NHQWl1M3FJbXdjbkpWc2NwSlNiS25peV8zYV9vdTdGbXFPMG5YNnpDSW1jWkVNX0EZD
In both cases I get the same object. With exactly the same Data. When I use browser for the 2 URLs, i get different (correct) data.
I even tried to request /me?fields=taggable_friends&access_token=myAccessToken&after=QWFKVko1NlJmWUREajBTeERZAbmFJUzlLUWp5ZA3o5cDA5SWVHc1BKblJ6ODMweDd4TzdxMlJyOTdKNDlUb0NHQWl1M3FJbXdjbkpWc2NwSlNiS25peV8zYV9vdTdGbXFPMG5YNnpDSW1jWkVNX0EZD in first call, but still I get the same data.
Finally i found the solution!
I don't know what the reason is, but API call like "/me?fields=taggable_friends&access_token=..." don't work when "after" parameter is added.
It should be used this way: "/me/taggable_friends?access_token=...", this way it works.