Snippets

Team Zoom Python - get all sent message using json

Updated by Terence Foxcroft

File python-get-all-sent-messages-using-json.py Modified

  • Ignore whitespace
  • Hide word diff
-# Request the all sent messages for an account
+# Request all sent messages for an account
 # This script makes use of the Requests Library: http://docs.python-requests.org/en/latest/
 
 import json
Updated by Terence Foxcroft

File python-get-all-sent-messages-using-json.py Modified

  • Ignore whitespace
  • Hide word diff
+# Request the all sent messages for an account
+# This script makes use of the Requests Library: http://docs.python-requests.org/en/latest/
+
+import json
+import requests
+
+email_address = 'YOUR_EMAIL_ADDRESS'
+rest_api_token = 'YOUR-API-TOKEN'
+base_url = 'https://www.zoomconnect.com/app/api/rest/v1/'
+
+def fetchPage(pageNumber):
+  url = base_url + 'messages/all.json?pageSize=10&page=' + str(pageNumber)
+  print 'Requesting ' + url
+  response = requests.get(url, auth=(email_address, rest_api_token))
+
+  if (response.ok):
+    print 'Response: ' + str(response.json()['elements']) + ' elements returned'
+	
+    messages = response.json()['webServiceMessages']
+    for message in messages:	
+	  print ' - ' + str(message['messageId']) + ' ' + str(message['toNumber']) + ' ' + str(message['messageStatus'])
+	
+    return pageNumber < response.json()['totalPages']
+  else:
+    print 'Request failed with response code ' + str(response.status_code)  
+    return False
+
+pageNumber = 1
+
+while True:  
+  hasNextPage = fetchPage(pageNumber)
+  pageNumber += 1
+  if(not hasNextPage):  
+    break
Created by Terence Foxcroft

File python-get-all-sent-messages-using-json.py Added

  • Ignore whitespace
  • Hide word diff
Empty file added.
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.