Webhooks
Webhooks
Los webhooks son devoluciones de llamada que se envían a una URL cuando se activa un determinado evento. Pueden utilizarse para integrar fácilmente StrawPoll con otros servicios.
Una solicitud de webhook enviará datos JSON al punto final. Las partes de la estructura de datos dependen del tipo de activación del evento.
Activadores de eventos
Actualmente, los webhooks pueden ser activados por los siguientes eventos:
- Crear encuesta ("create_poll")
- Actualizar la encuesta ("update_poll")
- Votar ("vote_poll")
- Fin del plazo ("deadline_poll")
- Restablecer la encuesta ("reset_poll")
- Borrar encuesta ("delete_poll")
Vea a continuación varios ejemplos de cargas útiles de solicitudes basadas en diferentes tipos de activación.
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" } } }