我在通讯中取消订阅链接时遇到问题,无法弄清楚我做错了什么。Sparkpost取消订阅和webhook
通讯中的链接是<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的测试网络挂接接口响应为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\":\"[email protected]\",\"mailfrom\":\"[email protected]\",\"message_id\":\"0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\",\"rcpt_meta\":{\"customKey\":\"customValue\"},\"rcpt_tags\":[\"male\",\"US\"],\"rcpt_to\":\"[email protected]\",\"raw_rcpt_to\":\"[email protected]\",\"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\":\"[email protected]\",\"mailfrom\":\"[email protected]\",\"message_id\":\"0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\",\"rcpt_meta\":{\"customKey\":\"customValue\"},\"rcpt_tags\":[\"male\",\"US\"],\"rcpt_to\":\"[email protected]\",\"raw_rcpt_to\":\"[email protected]\",\"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) ""
)。
我做错什么了吗?
所以纠正我,如果我错了 - 我想确认我理解这个问题。如果我正在阅读这个权利,您可以使用上面的方法将一个取消订阅链接添加到您的电子邮件中(这对我来说看起来是正确的)。然后你有一个你已经设置好的webhook,并且你想处理来自它的传入数据,对吗? – richleland
对不起,延迟回复,但是,这是正确的。 – praxus