sendgrid / sendgrid-php

The Official Twilio SendGrid PHP API Library
https://sendgrid.com
MIT License
1.49k stars 623 forks source link

docs: improve signed webhook event payload encoding #1102

Open emnsen opened 1 year ago

emnsen commented 1 year ago

If the payload contains slashed and if you encode the data manually, then the default json_encode function escapes the slashes which causes the verification to fail.

In my case, I decoded the payload with json_decode and then encoded it before the verification. However, the payload contained the user agent data, which has slashes, and the json_encode function was escaping the slashes, causing the verification to fail. So, I encoded the data like json_encode($payload, JSON_UNESCAPED_SLASHES) with the flag, and it started to verify successfully.