我在通訊中取消訂閱鏈接時遇到問題,無法弄清楚我做錯了什麼。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