]> git.ipfire.org Git - thirdparty/foundation/foundation-emails.git/commitdiff
Adding Header to Newsletter for API marketing
authorArthur <arthur@zurb.com>
Thu, 29 Oct 2015 20:31:45 +0000 (13:31 -0700)
committerArthur <arthur@zurb.com>
Thu, 29 Oct 2015 20:31:45 +0000 (13:31 -0700)
newsletter.php

index 6a72206036d6daf88637c2acc3179781b3aec7f5..0ece70175e79bacc437acc86ddcf5958287cbb0a 100644 (file)
@@ -1,24 +1,26 @@
 <?php
+  header('content-type: application/json; charset=utf-8');
+  header("access-control-allow-origin: *");
   if (isset($_POST['email'])) {
     $email = $_POST['email'];
-    $data = array("EmailAddress" => $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
+?>