I'm trying to figure out how to connect my signup to sender.net
API so when someone fills out the form it will be added to my subscriber list. Sender.net provided me with this information to help:
API is implemented through
HTTP
protocool, usingPOST
. Responses are returned in json.All API requested shall be directed at http://app.sneder.net/api/api.
Request data must be encoded in json, in
POST
parameter named data.
I wrote this code but nothing appears on my subscriber list, please see below:
<!DOCTYPE html>
<html>
<head>
<title>test with sender</title>
</head>
<body>
<h1>This is to test sender.net API "POST" </h1>
<form>
<input type="text" name="Fname" placeholder="first name">
<input type="text" name="Lname" placeholder="last name">
<input type="email" name="Email" placeholder="email address">
<button type="submit" onclick="JSONTest()"> Let the Post req begin!
</button>
</form>
<script type="text/javascript">
JSONTest = function() {
$.ajax({
url: "https://app.sender.net/api/",
method: "POST",
datatype: "JSON",
data: {
method: "listSubscribe",
params: {
api_key: "my key number",
list_id: "my id number",
emails: ["Email", "Fname", "Lname"],
update_existing: true
}
}
});
};
</script>
<!-- Jquery -->
<script src="vendor/jquery/jquery.min.js"></script>
</body>
</html>