From a4420a5048953d920df828c15a057e6c5f1152f1 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 29 Oct 2015 13:31:45 -0700 Subject: [PATCH] Adding Header to Newsletter for API --- newsletter.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/newsletter.php b/newsletter.php index 6a722060..0ece7017 100644 --- a/newsletter.php +++ b/newsletter.php @@ -1,24 +1,26 @@ $email, "Resubscribe" => TRUE); - $data_string = json_encode($data); - - $ch = curl_init("https://d275c8b5e96298ccb017e1c85bb47adb3dcfafbde61b53e5@api.createsend.com/api/v3/subscribers/5c6a55836de01f72133628c8343c520b.json"); - - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($data_string)) - ); + $data = array("EmailAddress" => $email, "Resubscribe" => TRUE); + $data_string = json_encode($data); - $result = curl_exec($ch); + $ch = curl_init("https://d275c8b5e96298ccb017e1c85bb47adb3dcfafbde61b53e5@api.createsend.com/api/v3/subscribers/5c6a55836de01f72133628c8343c520b.json"); + + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + + $result = curl_exec($ch); $success = strstr($result, '@'); curl_close($ch); echo !!$success; } else { echo 'Blah'; } -?> \ No newline at end of file +?> -- 2.47.2