Last active
April 3, 2017 16:51
-
-
Save marcosnakamine/3fe4d9412b67b4d2fcbbeba0609b2256 to your computer and use it in GitHub Desktop.
Sendy - Add contact in newsletter list via ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//------------------- Edit here --------------------// | |
$sendy_url = 'http://url'; | |
$list = 't'; // LIST ID | |
//------------------ /Edit here --------------------// | |
//--------------------------------------------------// | |
//POST variables | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
//subscribe | |
$postdata = http_build_query( | |
array( | |
'name' => $name, | |
'email' => $email, | |
'list' => $list, | |
'boolean' => 'true' | |
) | |
); | |
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); | |
$context = stream_context_create($opts); | |
$result = file_get_contents($sendy_url.'/subscribe', false, $context); | |
//--------------------------------------------------// | |
echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment