|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import messagebird |
| 4 | +import sys |
| 5 | +import os |
| 6 | +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 7 | + |
| 8 | + |
| 9 | +# ACCESS_KEY = '' |
| 10 | + |
| 11 | +try: |
| 12 | + # Create a MessageBird client with the specified ACCESS_KEY. |
| 13 | + client = messagebird.Client(ACCESS_KEY) |
| 14 | + |
| 15 | + # Fetch Voice Messages List from a specific offset, and within a defined limit. |
| 16 | + voiceMessageList = client.voice_message_list(limit=10, offset=0) |
| 17 | + |
| 18 | + # Print the object information. |
| 19 | + print('The following information was returned as a Voice Messages List object:') |
| 20 | + print(' Containing the following items:') |
| 21 | + print(voiceMessageList) |
| 22 | + for item in voiceMessageList.items: |
| 23 | + print(' {') |
| 24 | + print(' id : %s' % item.id) |
| 25 | + print(' href : %s' % item.href) |
| 26 | + print(' originator : %s' % item.originator) |
| 27 | + print(' body : %s' % item.body) |
| 28 | + print(' reference : %s' % item.reference) |
| 29 | + print(' language : %s' % item.language) |
| 30 | + print(' voice : %s' % item.voice) |
| 31 | + print(' repeat : %s' % item.repeat) |
| 32 | + print(' ifMachine : %s' % item.ifMachine) |
| 33 | + print(' scheduledDatetime : %s' % item.scheduledDatetime) |
| 34 | + print(' createdDatetime : %s' % item.createdDatetime) |
| 35 | + print(' recipients : %s\n' % item.recipients) |
| 36 | + print(' },') |
| 37 | + |
| 38 | + |
| 39 | +except messagebird.client.ErrorException as e: |
| 40 | + print('An error occured while requesting a Voice messages object list object:') |
| 41 | + |
| 42 | + for error in e.errors: |
| 43 | + print(' code : %d' % error.code) |
| 44 | + print(' description : %s' % error.description) |
| 45 | + print(' parameter : %s\n' % error.parameter) |
0 commit comments