我正在尝试弄清楚如何将我的注册连接到sender.net
API,因此当有人填写表单时,它会被添加到我的订阅者列表中。 Sender.net向我提供了这些信息以帮助:
API通过HTTP
protocool使用POST
实现。回复将在json。
请求的所有API均应指向http://app.sneder.net/api/api。
请求数据必须在json POST
参数命名数据中进行编码。
我写了这段代码,但我的订阅者列表中没有任何内容,请参阅下文:
<!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>
答案 0 :(得分:0)
<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="button" 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
}
},
success : function(response) {
console.log(response); // Feel free to Use debugger
}
});
};
</script>