akhil2909 / linkedin-j

Automatically exported from code.google.com/p/linkedin-j
0 stars 0 forks source link

setStart() not working on Posts.getPostList() #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am retrieving posts from a Linkedin Group into a Posts object using the 
getPostsByGroup method. This works correctly and gets multiple posts (more than 
10).

I use getPostList() to retrieve the individual posts from this Posts object but 
this seems to return only 10 posts at a time. I tried using setStart() to 
increment the start in intervals of 10 but this seems to have no effect and 
getPostList returns the same first ten posts repeatedly.

Is this the way we are supposed to retrieve multiple posts from a Posts object 
or am I missing something?

Thanks

Original issue reported on code.google.com by woostersoz on 19 Nov 2011 at 9:05

GoogleCodeExporter commented 9 years ago
hi 
I would request a response to the above question since I have an urgent 
deadline coming up for a client. Thanks in advance

Original comment by satyavr...@gmail.com on 9 Dec 2011 at 2:43

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
You will have to do paging using start and count parameters. e.g. The following 
example reads 10 posts per request.

int total = 0;
Posts posts = client.getPostsByGroup(idValue, 0, 10);
while (total < posts.getTotal()) {
    total += posts.getCount();
    // consume posts
    posts = client.getPostsByGroup(idValue, (int) (posts.getStart() + posts.getCount()), 10);

}

Original comment by nabeelmukhtar on 20 Dec 2011 at 7:58

GoogleCodeExporter commented 9 years ago
Thanks, Nabeel. However, my issue is that the getPostsByGroup correctly 
retrieves all the posts from a group. However, in order to examine the 
individual posts, I need to call getPostList on this Posts object. I cannot 
make getPostList retrieve more than 10 rows at a time.
Is this the intended behavior? If it is, I will change the way my code is  
structured but I wanted to check with you before I changed the code
thanks

Original comment by satyavr...@gmail.com on 20 Dec 2011 at 8:18

GoogleCodeExporter commented 9 years ago
You can specify a count of greater than 10. e.g. to get 20 rows each time
List<Post> allPosts = new ArrayList<Post>();
int total = 0;
Posts posts = client.getPostsByGroup(idValue, 0, 20);
while (total < posts.getTotal()) {
    total += posts.getCount();
    allPosts.addAll(posts.getPostList());
    posts = client.getPostsByGroup(idValue, (int) (posts.getStart() + posts.getCount()), 20);

}

Original comment by nabeelmukhtar on 20 Dec 2011 at 8:59