Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Last active July 19, 2016 21:17
Show Gist options
  • Save vanatteveldt/4ae7c7464c923008f8ff514228409577 to your computer and use it in GitHub Desktop.
Save vanatteveldt/4ae7c7464c923008f8ff514228409577 to your computer and use it in GitHub Desktop.
def get_all_connections(graph, id, connection, **args):
# Warning: method has been slightly edited manually from actual use, so may contain typos/mistakes
while True:
page = graph.get_connections(id, connection, **args)
for item in page['data']:
yield item
next = page.get('paging', {}).get('next')
if not next:
return
args = urlparse.parse_qs(urlparse.urlparse(next).query)
del args['access_token']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment