Search code examples
pythonpython-2.7google-reporting-api

Is param['pagetoken'] a syntax error in sample Google Reports Code?


I've been trying to decipher the following block of code from the Google Reports API sample

It appears as though the term param['pagetoken'] should be params['pagetoken']

Am I misreading this?

all_logins = []
page_token = None
params = {'applicationName': 'login', 'userKey': 'all', 'startTime': start_time}

while True:
  try:
    if page_token:
      param['pageToken'] = page_token
    current_page = reports_service.activities().list(**params).execute()

  all_logins.extend(current_page['items'])
  page_token = current_page.get('nextPageToken')
  if not page_token:
    break
except errors.HttpError as error:
  print 'An error occurred: %s' % error
  break

Solution

  • From what I can tell on the report page, that param[...] is a typo. param is not referred to anywhere else in the post, however params is.