Working with webhooks from Python SDK
Python SDK offers you a way to work with webhooks through the API.
Webhooks are great to know what is happening by simply listening on your server for things to happen. See bellow how you can use our API in regards to webhooks.
Python SDK Webooks Methods
- create Create a new webhook for the given url to catch the given events.
ziggeo.webhooks().create(arguments = None)
- target_url The url that will catch the events
- encoding Data encoding to be used by the webhook to send the events.
- events Comma-separated list of the events the webhook will catch. They must be valid webhook type events.
This method returns stringExample:import sys from Ziggeo import Ziggeo if(len(sys.argv) < 6): print ("Error\n") print ("Usage: $>python webhooks_create.py YOUR_API_TOKEN YOUR_PRIVATE_KEY WEBHOOK_URL ENCODING EVENTS\n") print ("Example: $>python webhooks_create.py 1234567890abcdef 1234567890abcdef http://yoursite.com jsonheader video_create,video_delete\n") sys.exit() api_token = sys.argv[1] private_key = sys.argv[2] target_url = sys.argv[3] encoding = sys.argv[4] # jsonheader, json, or form events = sys.argv[5] ziggeo = Ziggeo(api_token, private_key) arguments = {} arguments['target_url'] = target_url arguments['encoding'] = encoding arguments['events'] = events print(arguments) webhooks = ziggeo.webhooks().create(arguments) print(webhooks)
- confirm Confirm a webhook using its ID and the corresponding validation code.
ziggeo.webhooks().confirm(arguments = None)
- webhook_id Webhook ID that's returned in the creation call.
- validation_code Validation code that is sent to the webhook when created.
This method returns string - delete Delete a webhook using its URL.
ziggeo.webhooks().delete(arguments = None)
- target_url The url that will catch the events
This method returns stringExample:import sys from Ziggeo import Ziggeo if(len(sys.argv) < 4): print ("Error\n") print ("Usage: $>python webhooks_delete.py YOUR_API_TOKEN YOUR_PRIVATE_KEY WEBHOOK_URL \n") print ("Example: $>python webhooks_delete.py 1234567890abcdef 1234567890abcdef http://yoursite.com \n") sys.exit() api_token = sys.argv[1] private_key = sys.argv[2] target_url = sys.argv[3] ziggeo = Ziggeo(api_token, private_key) arguments = {} arguments['target_url'] = target_url ziggeo.webhooks().delete(arguments)