in this example, you disabled installation / pagination one at a time, I think my while loop is simple, as it searches for the keyword βnextβ, if it is not, if it does not exist, then we end the cycle and you will have the results in the list. in this example i'm just looking for all the people calling jacob
import requests import facebook token = access_token="your token goes here" fb = facebook.GraphAPI(access_token=token) limit = 1 offset = 0 data = {"q": "jacob", "type": "user", "fields": "id", "limit": limit, "offset": offset} req = fb.request('/search', args=data, method='GET') users = [] for item in req['data']: users.append(item["id"]) pag = req['paging'] while pag.get("next") is not None: offset += limit data["offset"] = offset req = fb.request('/search', args=data, method='GET') for item in req['data']: users.append(item["id"]) pag = req.get('paging') print users
source share