Linking Mailchimp to Sign-Up Boxes - php

I am linking an e-mail sign-up and a post code (UK English for zip code) input box (see html code below) to an existing Mailchimp e-mail list. I have taken out the $apiKey, $listId and $submit_url identifiers from the code below. I have been able to successfully link the Mailchimp list to the e-mail input (so that e-mail address are populated when they are input in the Mailchimp list but I cannot figure out how to get post codes to automatically update in mailchimp list when they are input).
I am relatively new to php and would be so grateful for any help.
<div class="subscribe">
<form method="post" action="bokacsubscribe.php" role="form">
<input type="email" placeholder="Enter your e-mail address..." class="subscribe-input" name="email" style="margin-bottom: 10px;">
<form method="post" action="bokacsubscribe.php" role="form">
<input type="email" placeholder="Enter your postcode" class="subscribe-input" name="postcode" style="margin-bottom: 10px;">
<button type="submit" class="btn btn-subscribe success" style="border-radius:120px;background-color:rgb(241,174,200);border:1px solid rgb(241,174,200)"><b>Send</b></button>
<input type="hidden" name="referr" id="referr"/>
</form>
</div>
</div>
<?php
// Credits: https://gist.github.com/mfkp/1488819
session_cache_limiter('nocache');
$apiKey = ''; - // How get your Mailchimp API KEY - http://kb.mailchimp.com/article/where-can-i-find-my-api-key
$listId = ''; - // How to get your Mailchimp LIST ID - http://kb.mailchimp.com/article/how-can-i-find-my-list-id
$submit_url = ""; - // Replace us2 with your actual datacenter
$double_optin = false;
$send_welcome = false;
$email_type = 'html';
$email = $_POST['email'];
$merge_vars = array( 'YNAME' => $_POST['yname'] );
$data = array(
'email_address' => $email,
'apikey' => $apiKey,
'id' => $listId,
'double_optin' => $double_optin,
'send_welcome' => $send_welcome,
'merge_vars' => $merge_vars,
'email_type' => $email_type
);
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $submit_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($payload));
$result = curl_exec($ch);
curl_close ($ch);
$data = json_decode($result);
if ($data->error) {
// do whatever you do on failure here
} else {
// do whatever you do on success here
$arrResult = array ('response'=>'success');
}

Related

How to log in with username or email using NATS API in php?

I have a login form that uses NATS API (Next-Generation Administration and Tracking System). In my form I have username and password fields that successfully log user on site. Now I want user to be able to also write his email if he wishes in username field and to be successfully logged in on site. I need to perform an additional search on that members email to get their username from NATS to authenticate them. Since I am using the member_auth table if a member enters an email address I would need to get the username from NATS using the API to perform the login. I need help on how to write that in this function that logs in user.
function.php
function elx_nats_api($endpoint = "member/details", $member_username, $member_email, $nats_site_id = 1){
$API_credentials["URL"] = "http://nats.site.com/api/";
$API_credentials["USR"] = "Oktogon";
$API_credentials["KEY"] = "51e2a35b50d9fd1f15a31827f32427edd";
if( $member_username == "" ) $member_username = $_SERVER["REMOTE_USER"];
// CURL
$curl = curl_init();
$data = array(
'username' => $member_username,
'email' => $member_email,
'full_info' => true,
'subscriptions' => true,
'siteid' => $nats_site_id
);
$data_string = http_build_query($data);
$url = $API_credentials["URL"] . $endpoint . "?" . $data_string;
$headers = array(
"api-key: ".$API_credentials["KEY"],
"api-username: ".$API_credentials["USR"]
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
$resp = curl_exec($curl);
$result = json_decode($resp, true);
// Close request to clear up some resources
curl_close($curl);
// Return the Result Array
return $result;
}
form.php
%%PRX_FORM%%
<div class="logbox">
<div class="box clear">
<h2>Members Area</h2>
<div class="logTypes">
<input type=text name=uid class="logtextbox" placeholder="Username">
<input type=password name=pwd class="logtextbox" placeholder="Password"><br>
<input type=text name=img class="logtextbox" placeholder="Enter the code shown below"></br>
<img style="margin: 0 auto;" src="/img.cptcha">
<div style="text-align: center">Remember my login: <input name=rmb type=checkbox value=”y”></div>
</div>
</div>
<input type="submit" value="submit" class="logBtn">
</div>
</form>
I am using NATS 4.1 and any help is appreciated.

MailChimp Add Subscriber using API 3.0 PHP

I am trying to add a php file that adds a new subscriber to my MailChimp list. Here is my form that SHOULD trigger the php file to add the new subscriber:
<form action="/scripts/freemonth_action.php" class="email_form_freemonth" method="post">
<h3>Get your first month free</h3>
<div class="form-group customised-formgroup"> <span class="icon-user"></span>
<input type="text" name="full_name" class="form-control" placeholder="Name">
</div>
<div class="form-group customised-formgroup"> <span class="icon-envelope"></span>
<input type="email" name="email" class="form-control" placeholder="Email">
</div>
<!--<div class="form-group customised-formgroup"> <span class="icon-telephone"></span>
<input type="text" name="phone" class="form-control" placeholder="Phone (optional)">
</div>-->
<div class="form-group customised-formgroup"> <span class="icon-laptop"></span>
<input type="text" name="website" class="form-control" placeholder="Website (optional)">
</div>
<!--<div class="form-group customised-formgroup"> <span class="icon-bubble"></span>
<textarea name="message" class="form-control" placeholder="Message"></textarea>
</div>-->
<div>
<br>
<button style="margin: 0 auto" type="submit" class="btn btn-fill full-width">GET FREE MONTH<span class="icon-chevron-right"></span></button>
</div>
</form>
And here is freemonth_action.php:
<?php
session_start();
if(isset($_POST['submit'])){
$name = trim($_POST['full_name']);
$email = trim($_POST['email']);
if(!empty($email) && !filter_var($email, FILTER_VALIDATE_EMAIL) === false){
// MailChimp API credentials
$apiKey = '6b610769fd3353643c7427db98d43ad6-us16';
$listID = '0cf013d1d9';
// MailChimp API URL
$memberID = md5(strtolower($email));
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID;
// member information
$json = json_encode([
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => [
'NAME' => $name,
]
]);
// send a HTTP POST request with curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo json_encode($result);
// store the status message based on response code
if ($httpCode == 200) {
$_SESSION['msg'] = '<p style="color: #34A853">You have successfully subscribed to CodexWorld.</p>';
} else {
switch ($httpCode) {
case 214:
$msg = 'You are already subscribed.';
break;
default:
$msg = 'Some problem occurred, please try again.';
break;
}
$_SESSION['msg'] = '<p style="color: #EA4335">'.$msg.'</p>';
}
}else{
$_SESSION['msg'] = '<p style="color: #EA4335">Please enter valid email address.</p>';
}
}
I'm not even sure how to debug this, because when i do echo $result (or anything like that) I do not see anything on the page or logged to the console. I'm also open to any suggestions that use javascript as long as it is still the 3.0 API.
Your subscription code works fine. The reason you aren't seeing any result is because isset($_POST['submit']) looks for an element with the name 'submit' rather than the type 'submit'. Just add the name attribute to your button, and it should work for you:
<button style="margin: 0 auto" type="submit" name="submit" class="btn btn-fill full-width">GET FREE MONTH<span class="icon-chevron-right"></span></button>
Also, you should keep the API key secret so other people can't access your MailChimp account through the API. I'd recommend disabling your current key and creating a new one. See MailChimp's knowledgebase article about API Keys for more details.

MailChimp group options select in php

I tried to find the answer for the last 5 hours but I finally caved in and am reaching out for help.
Basically, this code worked great until I needed to select a group option. I'm not sure if I'm creating my interests array properly, I may have to use 'merge_vars' but really would like some guidance before I spend another 5 hours blindly walking into walls.
Note for my group name I've been using the entire string "group[3117]"
Action.php
<?php
session_start();
if(isset($_POST['submit'])){
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$interest = $_POST['group[3117]'];
if(!empty($email) && !filter_var($email, FILTER_VALIDATE_EMAIL) === false){
// MailChimp API credentials
$apiKey = '+ insert api key here +';
$listID = 'insert list id';
$interest = 'insert group name'; // YOUR INTEREST/GROUP ID
// MailChimp API URL
$memberID = md5(strtolower($email));
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID;
// member information
$json = json_encode([
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => [
'FNAME' => $fname,
'LNAME' => $lname
],
'interests' => array(
$interest => true
),
]);
// send a HTTP POST request with curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// store the status message based on response code
if ($httpCode == 200) {
$_SESSION['msg'] = '<p style="color: #34A853">You have successfully subscribed to CodexWorld.</p>';
} else {
switch ($httpCode) {
case 214:
$msg = 'You are already subscribed.';
break;
default:
$msg = 'Some problem occurred, please try again.';
break;
}
$_SESSION['msg'] = '<p style="color: #EA4335">'.$msg.'</p>';
}
}else{
$_SESSION['msg'] = '<p style="color: #EA4335">Please enter valid email address.</p>';
}
}
// redirect to homepage
header('location:index.php');
Index.php
<?php session_start(); // place it on the top of the script ?>
<?php
$statusMsg = !empty($_SESSION['msg'])?$_SESSION['msg']:'';
unset($_SESSION['msg']);
echo $statusMsg;
?>
<form method="post" action="action.php">
<p><label>First Name: </label><input type="text" name="fname" /></p>
<p><label>Last Name: </label><input type="text" name="lname" /></p>
<p><label>Email: </label><input type="text" name="email" /></p>
<p><select name="group[3117]" class="REQ_CSS" id="mce-group[3117]">
<option value=""></option>
<option value="1">Los Angeles</option>
<option value="2">Seattle</option>
<option value="4">Portland</option> </p>
<p><input type="submit" name="submit" value="SUBSCRIBE"/></p>
</form>
Here's the solution, there's a lot of manual data entry but it works, if someone has an easier method please let me know.
Enter the MailChimp API playground. Select your list / subresources / interest-categories / interest name / subresources / interests / response . scroll down and there will be a unique "id" for interest. (ignore category id)
Here is the code, credit goes Mukesh Chapegan and CodexWorld
Name this page Action.php
<?php
$email = $_POST['email'];
$memberHash = md5($email);
$first_name = $_POST['fname'];
$last_name = $_POST['lname'];
$interest = $_POST['location'];
$api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; // YOUR API KEY
$server = 'us14.'; //last part of ur api key
$list_id = 'XXXXXXX'; // YOUR LIST ID
$auth = base64_encode( 'user:'.$api_key );
$data = array(
'apikey' => $api_key,
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => $first_name,
'LNAME' => $last_name
),
'interests' => array(
$interest => true
),
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'api.mailchimp.com/3.0/lists/'.$list_id.'/members/'.$memberHash);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '.$auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
$result_obj = json_decode($result);
echo $result_obj->status;
echo '<br>';
echo '<pre>'; print_r($result_obj); echo '</pre>';
?>
Here is the HTML form. name this index.php
Note I named the select element to location and the option values to the interest id I obtained through the API playground.
<?php session_start(); // place it on the top of the script ?>
<?php
$statusMsg = !empty($_SESSION['msg'])?$_SESSION['msg']:'';
unset($_SESSION['msg']);
echo $statusMsg;
?>
<form method="post" action="action.php">
<p><label>First Name: </label><input type="text" name="fname" /></p>
<p><label>Last Name: </label><input type="text" name="lname" /></p>
<p><label>Email: </label><input type="text" name="email" /></p>
<p> <select name="location" class="REQ_CSS" id="mce-group[3117]">
<option value=""></option>
<option value="f3eb68268d">Los Angeles</option>
<option value="3204c60199">Seattle</option>
<option value="3c5b8d638a">Portland</option> </p>
</select>
<p><input type="submit" name="submit" value="SUBSCRIBE"/></p>
</form>
If this answer helps please upvote so it's easier to find. I looked for this solution for a very very long time and found a lot of questions but few answers.

How to put POST form data in action

I am trying to setup a user creation API for VestaCP. I have these two pages.
The form:
<form action="process.php" method="post">
Username:<br>
<input type="text" name="username">
<br>
Password:<br>
<input type="password" name="password">
<br>
Email Address:<br>
<<input type="email" name="email">
<br><br>
<input type="submit" value="Submit">
</form>
Then the action:
<?php
// Server credentials
$vst_hostname = 'MYSERVERADDRESS';
$vst_username = 'MYSERVERUSERNAME';
$vst_password = 'MYSERVERPASSWORD';
$vst_command = 'v-add-user';
// New Account
$username = 'username';
$password = 'password';
$email = 'email';
$package = 'Free';
$fist_name = 'Null';
$last_name = 'Null';
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $password,
'arg3' => $email,
'arg4' => $package,
'arg5' => $fist_name,
'arg6' => $last_name
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
echo "User account has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}
?>
I think the problem is inputting the form data into the php script but I'm not very experienced so I don't know.
The API is connecting to my server correctly as I tested the same
//Server Credentials
part with a different API and it worked.
When I run this script, it outputs "User account has been successfully created" but when I check my control panel, there is no new user.
Thank you for any help.
EDIT: I only wrote the form, this script was made by VestaCP as shown here: https://vestacp.com/docs/api/. The errors in this script are direct from Vesta.
Try this:
<form action="process.php" method="post">
Username:<br>
<input type="text" name="username">
<br>
Firstname:<br>
<input type="text" name="firstname">
<br>
Name:<br>
<input type="text" name="name">
<br>
Password:<br>
<input type="password" name="password">
<br>
Email Address:<br>
<input type="email" name="email">
<br><br>
<input type="submit" value="Submit">
</form>
process.php
<?php
// Server credentials
$vst_hostname = 'MYSERVERADDRESS';
$vst_username = 'admin';
$vst_password = 'ADMINPASSWORD';
$vst_returncode = 'yes';
$vst_command = 'v-add-user';
// New Account
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$package = 'default'; // $package = 'Free'; //Free package exist on server?
$fist_name = $_POST['firstname'];
$last_name = $_POST['name'];
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $password,
'arg3' => $email,
'arg4' => $package,
'arg5' => $fist_name,
'arg6' => $last_name
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
echo "User account has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}
?>

How do I implement a MailChimp API form embed?

sorry for the perhaps naive question, but I have absolutely 0 experience in web design and I've been plowing through .html/.css for 2 days straight, and I think it's time I just seek some help.
I'm making a simple landing page for a conference, and I've been using a few templates. The most recent template I'm using is perfect, except the email signup sends direct emails to my account, rather than creating a list using a service such as mailchimp - highly inefficient.
A previous template I tried out, however, did implement mailchimp, and I was wondering how I might just grab its code and throw it in the current template I have.
Here is the subscribe.php from the mailchimp template:
<?php
$apiKey = '';
$listId = '';
$double_optin=true;
$send_welcome=true;
$email_type = 'html';
$email = $_POST['email'];
//replace us2 with your actual datacenter
$submit_url = "http://us1.api.mailchimp.com/1.3/?method=listSubscribe";
$data = array(
'email_address'=>$email,
'apikey'=>$apiKey,
'id' => $listId,
'double_optin' => $double_optin,
'send_welcome' => $send_welcome,
'email_type' => $email_type
);
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $submit_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($payload));
$result = curl_exec($ch);
curl_close ($ch);
$data = json_decode($result);
if ($data->error){
echo $data->error;
} else {
echo "Thanks! We'll keep you updated on the conference :)";
}
?>
and here is the snippet of code in index.html:
<div class="row">
<div class="col-md-6 col-sm-12 col-md-offset-3 subscribe">
<form class="form-horizontal" role="form" action="subscribe.php" id="subscribeForm" method="POST">
<div class="form-group">
<div class="col-md-7 col-sm-6 col-sm-offset-1 col-md-offset-0">
<input class="form-control input-lg" name="email" type="email" id="address" placeholder="Enter your email" data-validate="validate(required, email)" required="required">
</div>
<div class="col-md-5 col-sm-4">
<button type="submit" class="btn btn-success btn-lg">SIGN UP TO BE NOTIFIED</button>
</div>
</div>
</form>
<span id="result" class="alertMsg"></span> </div>
</div>
For reference, here are the subscribe.php and index.html snippets from the non-mailchimp template:
Subscribe.php
<?php
if ( isset( $_POST['newsletter_submit'] ) ) {
// Initialize error array
$newsletter_errors = array();
// Check email input field
if ( trim( $_POST['newsletter_email'] ) === '' )
$newsletter_errors[] = 'Email address is required';
elseif ( !preg_match( "/^[_\.0-9a-zA-Z-]+#([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z] {2,4}$/i", trim( $_POST['newsletter_email'] ) ) )
$newsletter_errors[] = 'Email address is not valid';
else
$newsletter_email = trim( $_POST['newsletter_email'] );
// Send email if no input errors
if ( empty( $newsletter_errors ) ) {
$email_to = "register#neustep.org"; // Change to your own email address
$subject = "NeuSTEP Subscription";
$body = "Subscriber details: " . $newsletter_email . "\r\n";
mail( $email_to, $subject, $body, $headers );
echo 'Thank you for subscribing!';
} else {
echo 'Please go back and correct the following errors:<br />';
foreach ( $newsletter_errors as $error ) {
echo $error . '<br />';
}}}
?>
Index.html snippet
<div class="newsletter">
<form action="subscribe.php" method="post" id="newsletter-form">
<p class="form-field">
<label for="newsletter_email" class="visually-hidden">Your email address</label>
<i class="icon ion-paper-airplane" aria-hidden="true"></i>
<input type="text" name="newsletter_email" id="newsletter_email" value="" placeholder="Your email address" />
</p>
<p class="form-submit">
<input type="submit" name="newsletter_submit" id="newsletter_submit" value="Get Notified" />
</p>
</form>
</div>
thanks for helping! sorry for the long post. I'm not sure what the etiquette on stackoverflow is, so if i'm asking a crappy question, let me know.
Your form is ok, and you need to implement a handler for subscribing like;
subscribe.php
<?php
if (empty($_POST["newsletter_email"]) {
die("You should provide email!");
} else if (!preg_match( "/^[_\.0-9a-zA-Z-]+#([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z] {2,4}$/i", trim( $_POST['newsletter_email'] ) )) {
die("Email address is not valid!");
} else {
$newsletter_email = trim( $_POST['newsletter_email'] );
}
$apiKey = '';
$listId = '';
$double_optin=true;
$send_welcome=true;
$email_type = 'html';
$email = $newsletter_email;
//replace us2 with your actual datacenter
$submit_url = "http://us1.api.mailchimp.com/1.3/?method=listSubscribe";
$data = array(
'email_address'=>$email,
'apikey'=>$apiKey,
'id' => $listId,
'double_optin' => $double_optin,
'send_welcome' => $send_welcome,
'email_type' => $email_type
);
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $submit_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($payload));
$result = curl_exec($ch);
curl_close ($ch);
$data = json_decode($result);
if ($data->error){
echo $data->error;
} else {
echo "Thanks! We'll keep you updated on the conference :)";
}
?>

Categories