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 1961 viewings related by tag "newsletters".
  2. Thought #EmailListVerify with 1160 viewings related by tag "newsletters".
  3. Thought Copy of - New Email List Manager System with 394 viewings related by tag "newsletters".
  4. Thought Project: Sparkpost for Speak To Me Catalog with 363 viewings related by tag "newsletters".
  5. Thought Diagram of Speak.txt system with 309 viewings related by tag "newsletters".
  6. Thought Well here i am back in this reality with 306 viewings related by tag "kudos".
  7. Thought [title (23251)] with 261 viewings related by tag "thanks".
  8. Thought Requirements for emailing with 247 viewings related by tag "newsletters".
  9. Thought (1) Sparkpost transaction to Update a template of the newsletter composed by the Reporter with 196 viewings related by tag "SparkPost".
  10. Thought (4) After mailing is finished - Sparkpost transaction to retrieve the bounces with 181 viewings related by tag "newsletters".
  11. Thought #SparkPost with 164 viewings related by tag "SparkPost".
  12. Thought How does blockchain go beyond what we already have in GCP ? with 137 viewings related by tag "thanks".
  13. Thought API Procedure to mail a Newsletter with 129 viewings related by tag "SparkPost".
  14. Thought To upload mp3 files to Fillmore box 6300 with 107 viewings related by tag "kudos".
  15. Thought Go Mark! with 102 viewings related by tag "kudos".
  16. Thought 2016C - FALL CD catalog production with 85 viewings related by tag "kudos".
  17. Thought Making up Others with 84 viewings related by tag "kudos".
  18. Thought Shout Out: Stay Hydrated but keep it in your pocket with 84 viewings related by tag "newsletters".
  19. Thought 3 state logic with 83 viewings related by tag "thanks".
  20. Thought REPORTER with 77 viewings related by tag "newsletters".
  21. Thought (3a & 3b) SparkPost transaction that acctually dispatches a mailing with 76 viewings related by tag "SparkPost".
  22. Thought BlackListt speaktomecatalog.com ... get speaktomecatalog off the list with 54 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 49 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 Fo Hammer popped up at the FBI today. with 43 viewings related by tag "kudos".
  30. Thought Pride & Thanks feel Good with 26 viewings related by tag "thanks".
  31. Thought Email Chatbots with SparkPost with 25 viewings related by tag "SparkPost".
  32. Thought Marketing Stratagies for Speak To Me Catalog with 20 viewings related by tag "SparkPost".
  33. Thought Footer problem on individual page at speaktomecatalog.com with 19 viewings related by tag "kudos".
  34. Thought Beard Gauge with 19 viewings related by tag "thanks".
  35. Thought Meatloaf with 17 viewings related by tag "kudos".
  36. Thought Lovely tag cloud! with 16 viewings related by tag "kudos".
  37. Thought A mailer in the Cloud with 16 viewings related by tag "newsletters".
  38. Thought Bookmarks Love with 15 viewings related by tag "kudos".
  39. Thought Your Role in the State of Email - Webinar with 15 viewings related by tag "newsletters".
  40. Thought Sweet Potato Fries with 13 viewings related by tag "thanks".
  41. Thought about: how it works - ideabuzz with 13 viewings related by tag "kudos".
  42. Thought Setting up a bounce domain for Sparkpost with 12 viewings related by tag "newsletters".
  43. Thought OMG We are back in business ... with 11 viewings related by tag "kudos".
  44. Thought Probably the most pertinant speech yet this century with 10 viewings related by tag "kudos".
  45. Thought 1711b with 10 viewings related by tag "newsletters".
  46. Thought 1711a with 8 viewings related by tag "newsletters".
  47. Thought sparkpost API documentation with 7 viewings related by tag "SparkPost".
  48. Thought Conversation Rooms with 1 viewings related by tag "kudos".
  49. Thought Coupon 1604a - Talk about those special times coming ... with 1 viewings related by tag "newsletters".
  50. Thought Coupon 1603c ... 10% off your highest valued item with 1 viewings related by tag "newsletters".