def get_photo_ids(g, aid):
	"""Retrieve all the photo IDs in a specified album."""
	photo_list = []

	conn_name = 'photos'
	while True:
		# Retrieve and parse the album IDs.
		photos = g.get_connections(id=aid, connection_name=conn_name)
		for photo in photos['data']:
			photo_list.append(photo['id'])

		# Continue the loop if next page exists.
		if 'next' in photos['paging']:
			next_cursor = photos['paging']['cursors']['after']
			conn_name = 'photos?after={}'.format(next_cursor)
		else:
			break

	return photo_list