Webhooks
Ereignisse via Webhooks senden
Webhooks sind Aufrufe, die an eine URL gesendet werden, wenn ein bestimmtes Ereignis ausgelöst wird. Sie können verwendet werden, um StrawPoll einfach mit anderen Diensten zu integrieren.
Eine Webhook-Anfrage sendet JSON-Daten an den Endpunkt. Teile der Datenstruktur hängen von der Art des Ereignisauslösers ab.
Ereignisauslöser
Webhooks können derzeit durch die folgenden Ereignisse ausgelöst werden:
- Umfrage erstellen ("create_poll")
- Umfrage aktualisieren ("update_poll")
- Abstimmen ("vote_poll")
- Fristende ("deadline_poll")
- Umfrage zurücksetzen ("reset_poll")
- Umfrage löschen ("delete_poll")
Nachstehend finden Sie verschiedene Beispiele für die Nutzlast von Anfragen, die auf unterschiedlichen Auslösertypen basieren.
Trigger "create_poll" - Create poll
{ "event": "create_poll", "timestamp": 1645702975, "data": { poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }
Trigger "update_poll" - Update poll
{ "event": "update_poll", "timestamp": 1645702975, "data": { poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }
Trigger "vote_poll" - Vote poll
{ "event": "vote_poll", "timestamp": 1645702975, "data": { vote => { { id => null, name => 'John Doe', vote_type => 'add', poll_votes => [1,0], } }, poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }
Trigger "deadline_poll" - Deadline ends
{ "event": "deadline_poll", "timestamp": 1645702975, "data": { poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }
Trigger "reset_poll" - Reset poll
{ "event": "reset_poll", "timestamp": 1645702975, "data": { poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }
Trigger "delete_poll" - Delete poll
{ "event": "delete_poll", "timestamp": 1645702975, "data": { poll: { "created_at": 1642684487, "creator": { "avatar_path": "/images/avatars/gregor-krambs-eNoZr17Gg3x.png", "created_at": 1642677936, "displayname": "Gregor Krambs", "username": "gregor-krambs" }, "id": "b7rnzxlZOl1", "is_votable": 1, "media": null, "path": "/polls/b7rnzxlZOl1", "pin_code": null, "poll_config": { "allow_comments": 1, "allow_other_option": 0, "allow_vpn_users": 0, "deadline_at": 1642685149, "duplication_checking": "ip", "edit_vote_permissions": "nobody", "hide_participants": 0, "is_multiple_choice": 0, "is_private": 0, "multiple_choice_max": 0, "multiple_choice_min": 0, "require_voter_names": 0, "results_visibility": "always", "send_notifications": 1, "send_webhooks": 1 }, "poll_meta": { "comment_count": 0, "creator_country": "de", "description": "", "location": "", "participant_count": 0, "timezone": null, "view_count": 0, "vote_count": 0 }, "poll_options": [ { "id": "Re7ZJ4Pn3Kb", "max_votes": 0, "media_id": null, "position": 0, "secondary": "", "value": "wat", "vote_count": 0 }, { "id": "540ZmRAyaRV", "max_votes": 0, "position": 1, "secondary": "", "value": "wat", "vote_count": 0 } ], "reset_at": 1642685161, "results_key": "f0c5bb06-79f2-11ec-ab86-43cfa7d8e06d", "results_path": "/polls/b7rnzxlZOl1/results", "slug": null, "status": "published", "title": "test", "type": "multiple_choice", "updated_at": 1642685150, "url": "https://strawpoll.de/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }