From: Arthur Date: Thu, 29 Oct 2015 20:31:45 +0000 (-0700) Subject: Adding Header to Newsletter for API X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmarketing;p=thirdparty%2Ffoundation%2Ffoundation-emails.git Adding Header to Newsletter for API --- 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 +?>