Unsubscribe to Speak To Me Catalog newsletter

About: Setting up Unsubscribe Links - SparkPost


To do
#newsletters #SparkPost #unsubscribes #webhooks

Tags

  1. newsletters
  2. SparkPost
  3. unsubscribes
  4. thanks
  5. kudos
  6. webhooks

Comments


Seth says
need to know how to extract the “rcpt_to” from the JSON post transaction …
from this hyperliink in the bulk email …
<a data-msys-unsubscribe="1"
href="YOUR_APP_UNSUBSCRIBE_HANDLER"
title="USEFUL_NAME">
UNSUBSCRIBE_LINK_DISPLAY_NAME
</a>
i assume i get this result in the POST transaction ...
[
{
    "msys": {
        "unsubscribe_event": {
            "template_version": "VERSION_NUMBER_OF_TEMPLATE",
            "template_id": "TEMPLATE_ID_VALUE",
            "ip_address": "IP_ADDRESS_OF_THE_UNSUBSCRIBE_SOURCE",
            "target_link_url": "HREF_OF_UNSUBSCRIBE_LINK",
            "timestamp": "UNIX_TIMESTAMP_WHEN_UNSUBSCRIBE_CLICK_OCCURRED",
            "rcpt_tags": [
                "ARRAY_OF_STRINGS_IN_TAGS_PROPERTY_OF_TRANSMISSION"
            ],
            "customer_id": "YOUR_SPARKPOST_ACCOUNT_ID",
            "transmission_id": "SPARKPOST_TRANSMISSION_ID",
            "user_agent": "USER_AGENT_STRING",
            "type": "link_unsubscribe",
            "rcpt_meta": {
                "META_KEYS": "META_VALUES"
            },
            "message_id": "MESSAGE_ID",
            "rcpt_to": "RECIPIENT_EMAIL_ADDRESS",
            "accept_language": "en-US,en;q=0.8",
            "target_link_name": "NAME_OF_UNSUBSCRIBE_LINK"
        }
    }
}
]



Seth says
hmmm … see this … hopefully available in my version
<?php
$json 
’{"a":1,"b":2,"c":3,"d":4,"e":5}’;

var_dump(json_decode($json));
var_dump(json_decode($jsontrue));

?>

Si says
true in json_decode simply makes it an associative array instead of an object. Which only affects the syntax you then use to access it’s parts.

For the first it would be $j->a and $j->b

For the second it would be $j[‘a’] and $j[‘b’]

Otherwise, all is the same … including print_f() and var_dump() … except that associative arrays are just a micro hair faster to access than objects … but only an amount a benchmark test could notice.

Seth says
the problem is, that given the sparkpost POST (specified i guess in Unsubscribe to Speak To Me Catalog newsletter (comment 77012))

and this code in my program …
<?php
$r=json_decode(file_get_contents(’php://input’),true);
$rcpt_to= "email=" . $r[’msys’][’unsubscribe_event’][’rcpt_to’];
echo $rcpt_to;
exit;
?>

The response according to sparkpost is …

Your server responded like this:   (in other words, i don’t know how to retrieve the data from the tree)

HTTP/1.1 200
Date: Wed, 03 May 2017 21:34:24 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

"email="

Si says
Okay. By what you “assumed” the post should look like, it would have worked.

What does the post data really look like?

Seth says
"Array\n(\n [0] => Array\n (\n [msys] => Array\n (\n [unsubscribe_event] => Array\n (\n [type] => link_unsubscribe\n [campaign_id] => Example Campaign Name\n [customer_id] => 1\n [delv_method] => esmtp\n [event_id] => 92356927693813856\n [friendly_from] => sender@example.com\n [ip_address] => 127.0.0.1\n [ip_pool] => Example-Ip-Pool\n [mailfrom] => recipient@example.com\n [message_id] => 000443ee14578172be22\n [msg_from] => sender@example.com\n [msg_size] => 1337\n [num_retries] => 2\n [queue_time] => 12\n [rcpt_meta] => Array\n (\n [customKey] => customValue\n )\n\n [rcpt_tags] => Array\n (\n [0] => male\n [1] => US\n )\n\n [rcpt_to] => recipient@example.com\n [raw_rcpt_to] => recipient@example.com\n [rcpt_type] => cc\n [routing_domain] => example.com\n [sending_ip] => 127.0.0.1\n [subaccount_id] => 101\n [subject] => Summer deals are here!\n [template_id] => templ-1234\n [template_version] => 1\n [timestamp] => 1454442600\n [transmission_id] => 65832150921904138\n [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\n )\n\n )\n\n )\n\n)\nemail="
which is from …
$r=json_decode(file_get_contents(’php://input’),true);
print_r($r);

 

Seth says
from …

<?php
$raw=file_get_contents(’php://input’);
echo $raw;
exit;


here is the result …
[{"msys":{"unsubscribe_event":{"type":"link_unsubscribe","campaign_id":"Example Campaign Name","customer_id":"1","delv_method":"esmtp","event_id":"92356927693813856","friendly_from":"sender@example.com","ip_address":"127.0.0.1","ip_pool":"Example-Ip-Pool","mailfrom":"recipient@example.com","message_id":"000443ee14578172be22","msg_from":"sender@example.com","msg_size":"1337","num_retries":"2","queue_time":"12","rcpt_meta":{"customKey":"customValue"},"rcpt_tags":["male","US"],"rcpt_to":"recipient@example.com","raw_rcpt_to":"recipient@example.com","rcpt_type":"cc","routing_domain":"example.com","sending_ip":"127.0.0.1","subaccount_id":"101","subject":"Summer deals are here!","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"}}}]

… looks to me that the array is nested in an extra [  … ]

Si says
Yep. They must be able to send you multiple.

So just,

$r = file_get_contents(’php://input’);
$r = json_decode($r, true);
$r = $r[0];
$email = $r[’msys’][’unsubscribe_event’][’rcpt_to’];
...
 

Seth says
Success …
#thanks → nathan

&

#kudos → nathan

nullnull

Si says

See Also

  1. Thought Newsletter Mailing System with 1965 viewings related by tag "newsletters".
  2. Thought #EmailListVerify with 1162 viewings related by tag "newsletters".
  3. Thought Copy of - New Email List Manager System with 396 viewings related by tag "newsletters".
  4. Thought Project: Sparkpost for Speak To Me Catalog with 371 viewings related by tag "newsletters".
  5. Thought Well here i am back in this reality with 312 viewings related by tag "kudos".
  6. Thought Diagram of Speak.txt system with 310 viewings related by tag "newsletters".
  7. Thought [title (23251)] with 262 viewings related by tag "thanks".
  8. Thought Requirements for emailing with 249 viewings related by tag "newsletters".
  9. Thought (4) After mailing is finished - Sparkpost transaction to retrieve the bounces with 201 viewings related by tag "newsletters".
  10. Thought (1) Sparkpost transaction to Update a template of the newsletter composed by the Reporter with 196 viewings related by tag "SparkPost".
  11. Thought #SparkPost with 175 viewings related by tag "SparkPost".
  12. Thought How does blockchain go beyond what we already have in GCP ? with 139 viewings related by tag "thanks".
  13. Thought API Procedure to mail a Newsletter with 132 viewings related by tag "SparkPost".
  14. Thought To upload mp3 files to Fillmore box 6300 with 129 viewings related by tag "kudos".
  15. Thought Go Mark! with 102 viewings related by tag "kudos".
  16. Thought 3 state logic with 93 viewings related by tag "thanks".
  17. Thought Shout Out: Stay Hydrated but keep it in your pocket with 90 viewings related by tag "newsletters".
  18. Thought 2016C - FALL CD catalog production with 86 viewings related by tag "kudos".
  19. Thought Making up Others with 85 viewings related by tag "kudos".
  20. Thought (3a & 3b) SparkPost transaction that acctually dispatches a mailing with 77 viewings related by tag "SparkPost".
  21. Thought REPORTER with 77 viewings related by tag "newsletters".
  22. Thought BlackListt speaktomecatalog.com ... get speaktomecatalog off the list with 57 viewings related by tag "newsletters".
  23. Thought Amazon's Buy Box Games with 52 viewings related by tag "kudos".
  24. Thought 1705a with 52 viewings related by tag "newsletters".
  25. Thought (2) Post the mailing list to SparkPost with 52 viewings related by tag "SparkPost".
  26. Thought Speak.txt - mailing Procedure with 50 viewings related by tag "newsletters".
  27. Thought Shout Out: Trump is back by popular demand ! (2017-01-17) with 50 viewings related by tag "newsletters".
  28. Thought Speak To Me Catalog will donate 10% of every sale on these products with 45 viewings related by tag "newsletters".
  29. Thought Setting up a bounce domain for Sparkpost with 44 viewings related by tag "newsletters".
  30. Thought Fo Hammer popped up at the FBI today. with 43 viewings related by tag "kudos".
  31. Thought Pride & Thanks feel Good with 26 viewings related by tag "thanks".
  32. Thought Email Chatbots with SparkPost with 25 viewings related by tag "SparkPost".
  33. Thought Marketing Stratagies for Speak To Me Catalog with 20 viewings related by tag "SparkPost".
  34. Thought Footer problem on individual page at speaktomecatalog.com with 19 viewings related by tag "kudos".
  35. Thought Beard Gauge with 19 viewings related by tag "thanks".
  36. Thought Meatloaf with 17 viewings related by tag "kudos".
  37. Thought Lovely tag cloud! with 16 viewings related by tag "kudos".
  38. Thought A mailer in the Cloud with 16 viewings related by tag "newsletters".
  39. Thought Bookmarks Love with 15 viewings related by tag "kudos".
  40. Thought Your Role in the State of Email - Webinar with 15 viewings related by tag "newsletters".
  41. Thought Sweet Potato Fries with 13 viewings related by tag "thanks".
  42. Thought about: how it works - ideabuzz with 13 viewings related by tag "kudos".
  43. Thought Probably the most pertinant speech yet this century with 11 viewings related by tag "kudos".
  44. Thought 1711b with 11 viewings related by tag "newsletters".
  45. Thought OMG We are back in business ... with 11 viewings related by tag "kudos".
  46. Thought 1711a with 8 viewings related by tag "newsletters".
  47. Thought sparkpost API documentation with 7 viewings related by tag "SparkPost".
  48. Thought Conversations are Kewl with 6 viewings related by tag "kudos".
  49. Thought Coupon 1604a - Talk about those special times coming ... with 3 viewings related by tag "newsletters".
  50. Thought Conversation Rooms with 1 viewings related by tag "kudos".