Webhooks
Webhooks
Les Webhooks sont des callbacks qui sont envoyés à une URL lorsqu'un certain événement est déclenché. Ils peuvent être utilisés pour intégrer facilement StrawPoll à d'autres services.
Une requête webhook enverra des données JSON au point de terminaison. Les parties de la structure de données dépendent du type de déclencheur d'événement.
Déclencheurs d'événements
Les Webhooks peuvent actuellement être déclenchés par les événements suivants :
- Créer un sondage ("create_poll")
- Mise à jour du sondage ("update_poll")
- Vote ("vote_poll")
- Fin du délai ("deadline_poll")
- Réinitialiser le sondage ("reset_poll")
- Supprimer le sondage ("delete_poll")
Voir ci-dessous pour divers exemples de charges utiles de demande basées sur différents types de déclencheurs.
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.com/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.com/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.com/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.com/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.com/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.com/polls/b7rnzxlZOl1", "version": "82ae4ffa-79f4-11ec-a974-bc4baeb948a2" } } }