API 接口文档
用于向本系统提交线索数据。适用于自行开发前端的站长。
一、基本信息
| 项目 | 说明 |
| 接口地址 | https://ecrm.eooele.com/api.php |
| 请求方式 | POST |
| 数据格式 | application/x-www-form-urlencoded(普通表单) |
| 返回格式 | JSON |
| 字符编码 | UTF-8 |
获取 API Key:登录站长后台 → 配置页 → 复制「API Key」。
二、请求参数
必填参数
| 参数 | 类型 | 说明 |
key | string | 你的 API Key |
线索字段(按你后台的字段配置提交)
| 参数 | 类型 | 说明 |
nickname | string | 姓名 |
country_code | string | 国家区号,如 +86 |
phone | string | 电话 |
email | string | 邮箱 |
wechat | string | 微信号 |
company | string | 公司 |
country | string | 国家 |
content | string | 留言内容 |
remark | string | 备注 |
可选参数
| 参数 | 类型 | 说明 |
platform | string | 广告平台标识,如 google、facebook。决定执行哪段转化追踪代码,也会显示在线索来源里 |
source | string | 来源标识(自由填写),如 google-ads-1、官网。不传默认 api。仅作记录,列表页优先显示 platform |
page_url | string | 来源页面 URL |
platform 和 source 的区别:
· platform = 哪个广告平台(决定执行哪段追踪代码)
· source = 更细的来源标记(可选,仅记录)
一般只传 platform 就够了。
哪些字段必填,取决于你在后台「字段配置」里的设置。
三、返回格式
成功
{
"code": 0,
"msg": "提交成功",
"data": {
"id": 123,
"track_code": "<script>gtag('event','conversion',{...});</script>",
"redirect_url": "https://example.com/thanks",
"redirect_delay": 5
}
}
| 字段 | 说明 |
id | 线索 ID |
track_code | 对应平台的转化追踪代码,由你在后台配置。可执行它通知广告平台 |
redirect_url | 后台设置的跳转网址,空则不跳转 |
redirect_delay | 跳转等待秒数,3 / 5 / 10 |
失败
{
"code": 1001,
"msg": "无效的 key"
}
错误码
| code | 说明 |
0 | 成功 |
1001 | 无效的 key |
1003 | 请求方法错误(必须 POST) |
1004 | 提交太频繁(同 IP 60 秒一次) |
1005 | 字段校验失败 |
四、接入示例
1. HTML 表单直接提交(最简单)
<form action="https://ecrm.eooele.com/api.php" method="post">
<input type="hidden" name="key" value="你的API_KEY">
<input type="text" name="nickname" placeholder="姓名">
<input type="text" name="phone" placeholder="电话">
<input type="email" name="email" placeholder="邮箱">
<textarea name="content" placeholder="留言内容"></textarea>
<button type="submit">提交</button>
</form>
提交后会跳到 api.php 显示 JSON。如果只是测试接口,用这个即可。
2. JavaScript(fetch)
const fd = new FormData();
fd.append('key', '你的API_KEY');
fd.append('nickname', '张三');
fd.append('phone', '13800138000');
fd.append('email', 'zhangsan@example.com');
fd.append('content', '我想了解产品报价');
fd.append('platform', 'google');
fd.append('page_url', window.location.href);
fetch('https://ecrm.eooele.com/api.php', {
method: 'POST',
body: fd
})
.then(r => r.json())
.then(res => {
if (res.code === 0) {
alert('提交成功');
} else {
alert(res.msg);
}
});
3. PHP 服务端提交
<?php
$data = [
'key' => '你的API_KEY',
'nickname' => '张三',
'phone' => '13800138000',
'email' => 'zhangsan@example.com',
'content' => '我想了解产品报价',
];
$ch = curl_init('https://ecrm.eooele.com/api.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$json = json_decode($res, true);
if ($json['code'] === 0) {
echo '提交成功';
}
五、完整示例(含转化追踪 + 自动跳转)
下面是一个完整可用的页面。复制 → 改 API Key → 保存为 .html → 传到网站,就能用。不用懂后端。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>联系我们</title>
<style>
body { font-family: Arial, sans-serif; max-width: 500px; margin: 40px auto; padding: 0 20px; }
input, textarea { width: 100%; padding: 10px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; font-size: 14px; }
textarea { min-height: 90px; }
button { width: 100%; padding: 12px; background: #2563eb; color: #fff; border: none; border-radius: 4px; font-size: 15px; cursor: pointer; }
button:disabled { background: #999; }
#result { text-align: center; padding: 30px 20px; color: #16a34a; font-size: 16px; }
</style>
</head>
<body>
<form id="leadForm">
<h2 style="text-align:center;">联系我们</h2>
<input type="text" name="nickname" placeholder="姓名" required>
<input type="text" name="phone" placeholder="电话">
<input type="email" name="email" placeholder="邮箱">
<textarea name="content" placeholder="留言内容"></textarea>
<button type="submit">提交</button>
</form>
<div id="result" style="display:none;"></div>
<script>
document.getElementById('leadForm').onsubmit = function(e) {
e.preventDefault();
var btn = this.querySelector('button');
btn.disabled = true;
btn.textContent = '提交中...';
var fd = new FormData(this);
fd.append('key', '你的API_KEY'); // ← 改这里
fd.append('platform', 'google'); // ← 改这里(对应你后台配置的平台)
// fd.append('source', 'google-ads-1'); // 可选:细分来源标记
fd.append('page_url', window.location.href);
fetch('https://ecrm.eooele.com/api.php', {
method: 'POST',
body: fd
})
.then(function(r) { return r.json(); })
.then(function(res) {
if (res.code !== 0) {
alert(res.msg);
btn.disabled = false;
btn.textContent = '提交';
return;
}
// ===== 执行转化追踪代码 =====
if (res.data.track_code) {
var div = document.createElement('div');
div.innerHTML = res.data.track_code;
var scripts = div.querySelectorAll('script');
if (scripts.length === 0) {
var s = document.createElement('script');
s.textContent = res.data.track_code;
document.body.appendChild(s);
} else {
scripts.forEach(function(old) {
var s = document.createElement('script');
if (old.src) { s.src = old.src; } else { s.textContent = old.textContent; }
document.body.appendChild(s);
});
}
}
// ===== 显示成功 / 跳转 =====
document.getElementById('leadForm').style.display = 'none';
var result = document.getElementById('result');
result.style.display = 'block';
result.innerHTML = '✓ 提交成功!';
var url = res.data.redirect_url;
var delay = res.data.redirect_delay || 5;
if (url) {
var sec = delay;
result.innerHTML = '✓ 提交成功!<br>' + sec + ' 秒后自动跳转...';
var timer = setInterval(function() {
sec--;
if (sec <= 0) {
clearInterval(timer);
window.location.href = url;
} else {
result.innerHTML = '✓ 提交成功!<br>' + sec + ' 秒后自动跳转...';
}
}, 1000);
}
})
.catch(function() {
alert('网络错误,请重试');
btn.disabled = false;
btn.textContent = '提交';
});
};
</script>
</body>
</html>
六、跳转设置说明
| 字段 | 说明 |
redirect_url | 站长后台设置的跳转网址,空则不跳转 |
redirect_delay | 等待秒数,3 / 5 / 10 |
在 站长后台 → 配置页 → 提交成功跳转设置 里修改。
七、注意事项
| 事项 | 说明 |
| 提交频率 | 同一 IP 60 秒内只能成功提交 1 次 |
| 内容安全 | 提交内容会被过滤,请勿提交 HTML 标签 |
| 数据读取 | 本接口仅用于「写入」,读取请登录后台查看 |
| 平台标识 | platform 的值要和你后台配置的平台 key 一致 |
不想写代码?直接用一键嵌入,在页面加一行:
<script src="https://ecrm.eooele.com/embed.js?key=你的API_KEY"></script>
多平台投放加参数:
&platform=google