Php Sparkpost取消订阅和webhook

Php Sparkpost取消订阅和webhook,php,unsubscribe,sparkpost,Php,Unsubscribe,Sparkpost,我对取消订阅时事通讯中的链接有问题,无法找出我做错了什么 通讯中的链接是“ 我已经用相同的目标URL创建了一个webhook,它似乎会被触发,因为它说“哦,是的!最后一批成功交付日期为2016年3月4日上午10:02” 我是用PHP实现的,起初我认为我没有正确地阅读它(使用file\u get\u contents('php://input“)但当我尝试从Sparkpost webhook接口进行测试时,var\u dump(file\u get\u contents('php://input)

我对取消订阅时事通讯中的链接有问题,无法找出我做错了什么

通讯中的链接是

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

我是用PHP实现的,起初我认为我没有正确地阅读它(使用
file\u get\u contents('php://input“)
但当我尝试从Sparkpost webhook接口进行测试时,
var\u dump(file\u get\u 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"
HTTP/1.1200
日期:2016年3月4日星期五09:17:57 GMT
服务器:Apache
X-Powered-By:PHP/5.5.32
内容长度:1290
连接:关闭
内容类型:text/html;字符集=utf-8
“字符串(1254)\”[{“msys\”:{“取消订阅事件\”:{“类型\”:“列表取消订阅\”,“活动id\”:“示例活动名称\”,“客户id\”:“1\”,“活动id\”:“92356927693813856\”,“来自”的友好用户::”sender@example.com\“,\“mailfrom\”:\”recipient@example.com\“,”消息id\“:\”0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\“,”rcpt\U meta\“:{”自定义密钥“:\”自定义值\“},\“rcpt\U标记\:[\“男性\”,“美国\],\“rcpt\U到\”:”recipient@example.com\“,\“未加工的rcpt\”:\”recipient@example.com\“,”rcpt\U type\“:”cc\“,”子帐户id\“:”101\“,”模板id\“:”templ-1234\“,”模板版本\“:”1\“,”时间戳\“:1454442600,\”传输id \“:”65832150921904138\”}},{”msys\“:{”取消订阅事件\“:{”类型\“链接“取消订阅”、“活动id”:“示例活动名称”、“客户id”:“1”、“活动id”:“92356927693813856”、“友好的”来自sender@example.com\“,\“mailfrom\”:\”recipient@example.com\“,”消息id\“:\”0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e\“,”rcpt\U meta\“:{”自定义键\“:”自定义值\“},\”rcpt\U标签\:[”男性\“,”美国\“],”rcpt\U to \“:”recipient@example.com\“,\“未加工的rcpt\”:\”recipient@example.com\“,”rcpt\U type\“:”cc\“,”子帐户id\“:”101\“,”模板id\“:”templ-1234\“,”模板版本“:”1\“,”时间戳“:”1454442600,”传输id“:”65832150921904138“,”用户代理“:”Mozilla/5.0(麦金塔;英特尔Mac OS X 10\U 10\U 3)AppleWebKit/537.36(如Gekhtml)Chrome/41.0.2272.118 Safari/537.36\“}}}]\“\n字符串(2)\“qq\”\n”
在新闻稿中单击“取消订阅”链接时,相同的转储为空字符串(
string(0)”“


我做错什么了吗?

我也有同样的问题。 我认为来自unsubscribe链接的URL不需要与webhook相同

将结果写入文件,而不是打印到屏幕上。
您将看到,在单击“取消订阅”链接几秒钟/分钟后,它将获得数据。

我希望根据这个问题的日期,您已经有了答案,因此我将把它放在这里给下一个人

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

以下是SparkPost的一份文件,详细描述了这一点:

如果您需要一种快速测试方法,可以在此处使用我的WebHook监视器:

或者在此处使用运行版本:


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

,因此,如果我错了,请纠正我-我想确认我理解这个问题。如果我读对了,您已经使用上述方法在您的电子邮件中添加了一个取消订阅链接(我认为这是正确的)。然后,您就有了一个已设置的webhook,并且您希望处理来自该webhook的传入数据,对吗?很抱歉,延迟回复,但是的,这是正确的。