How to use cursors to iterate through result set of GET followers/list using c#?


#1

I have been trying a way to get the data in the next page of the result set of GET followers/list API call. I can get the default data set with the data of first 20 followers and not the others. To get the data of other followers i have to access the next page using the next_cursor but it’s not working. I tried using the pseudo-code mentioned in this link. https://dev.twitter.com/docs/misc/cursoring

Is it a must to use this:
api-path, “https://api.twitter.com/1.1/endpoint.json?screen_name=targetUser

Because i have been using the resource url as,
var resource_url = “https://api.twitter.com/1.1/followers/list.json”;

and i tried appending the next_cursor to the same resource url.
var url_with_cursor = resource_url + “&cursor=” + 1463101490306580067;

and then created the request.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url_with_cursor);

but i’m getting an exception in this line when getting the response.
WebResponse response = request.GetResponse();

Can someone tell the exact way to do cursoring. Thanks.


#2

You should keep the parameters you gave to the endpoint when you got that cursor. So the URL should be of the form https://api.twitter.com/1.1/followers/list.json?screen_name=targetuser&cursor=1463101490306580067, not https://api.twitter.com/1.1/followers/list.json&cursor=1463101490306580067.
targetuser is of course the user you are interested in. It would be of the form https://api.twitter.com/1.1/followers/list.json?user_id=123456&cursor=1463101490306580067 if you use a user id to identify the user.