3

我在时事通讯中的取消订阅链接有问题,无法弄清楚我做错了什么。

时事通讯中的链接是<a title="Unsubscribe" data-msys-unsubscribe="1" href="https://example.com/en/site/unsubscribe">Unsubscribe</a>"

我创建了一个具有相同目标 URL 的 webhook,它似乎被触发了,因为它说“哦,是的!最后一批成功交付于 2016 年 3 月 4 日上午 10:02”。

我在 PHP 中实现它,起初我以为我没有正确阅读它(使用file_get_contents('php://input')但当我尝试从 Sparkpost webhook 接口进行测试时,响应var_dump(file_get_contents('php://input'))是:

HTTP/1.1 200
Date: Fri, 04 Mar 2016 09:17:57 GMT
Server: Apache
X-Powered-By: PHP/5.5.32
Content-Length: 1290
Connection: close
Content-Type: text/html; charset=utf-8

"<pre>string(1254) \"[{\"msys\":{\"unsubscribe_event\":{\"type\":\"list_unsubscribe\",\"campaign_id\":\"Example Campaign Name\",\"customer_id\":\"1\",\"event_id\":\"92356927693813856\",\"friendly_from\":\"sender@example.com\",\"mailfrom\":\"recipient@example.com\",\"message_id\":\"0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\",\"rcpt_meta\":{\"customKey\":\"customValue\"},\"rcpt_tags\":[\"male\",\"US\"],\"rcpt_to\":\"recipient@example.com\",\"raw_rcpt_to\":\"recipient@example.com\",\"rcpt_type\":\"cc\",\"subaccount_id\":\"101\",\"template_id\":\"templ-1234\",\"template_version\":\"1\",\"timestamp\":1454442600,\"transmission_id\":\"65832150921904138\"}}},{\"msys\":{\"unsubscribe_event\":{\"type\":\"link_unsubscribe\",\"campaign_id\":\"Example Campaign Name\",\"customer_id\":\"1\",\"event_id\":\"92356927693813856\",\"friendly_from\":\"sender@example.com\",\"mailfrom\":\"recipient@example.com\",\"message_id\":\"0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\",\"rcpt_meta\":{\"customKey\":\"customValue\"},\"rcpt_tags\":[\"male\",\"US\"],\"rcpt_to\":\"recipient@example.com\",\"raw_rcpt_to\":\"recipient@example.com\",\"rcpt_type\":\"cc\",\"subaccount_id\":\"101\",\"template_id\":\"templ-1234\",\"template_version\":\"1\",\"timestamp\":1454442600,\"transmission_id\":\"65832150921904138\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36\"}}}]\"\nstring(2) \"qq\"\n"

单击时事通讯中的取消订阅链接时,相同的转储是一个空字符串 ( string(0) "")。

难道我做错了什么?

4

2 回答 2

1

我遇到了同样的问题。我认为取消订阅链接的 URL 不需要与 webhook 相同。

不要将结果打印到屏幕上,而是将其写入文件。您会看到,在您点击退订链接几秒钟/几分钟后,它将获得数据。

于 2016-03-22T13:26:34.127 回答
1

我希望根据这个问题的日期,你已经有了答案,所以我会把它放在这里给下一个人。

取消订阅链接不需要与您的 webhook 端点相同。它的工作方式是您将获得“取消订阅” webhook 事件,但用户也将被重定向到您提供的链接。

这是 SparkPost 的一个文档,更详细地描述了这一点: https ://www.sparkpost.com/docs/user-guide/setting-up-unsubscribe-links/

如果您需要快速测试方法,可以在此处使用我的 WebHook 监视器: https ://github.com/yepher/webhook_monitor

或者在这里使用运行版本:http ://webhook.yepher.com:3000/

当您访问该页面时,您将获得一个“唯一”的 URL。只需将其添加为您的 webhook 之一。然后发送电子邮件并单击取消订阅链接。稍等片刻,您将看到“取消订阅事件”。您可以打开第二个 webhook 监视器并将其用作“取消订阅链接”,然后您将看到两者。webhook 事件将是“POST”,最终用户的实际点击将是“GET”

于 2017-08-22T19:16:55.213 回答