clickfunnels 中的说明让我从创建测试端点 URL 开始:
。创建测试端点。
首先,您需要在
<your-domain/funnel_webhooks/test>
创建一个测试端点
它应该包含下面的标题。
Content-Type
为 application/json
X-Clickfunnels-Webhook-Delivery-Id
作为 URL 和 Payload 的 MD5。
有效负载(HTTP 消息正文)将是一个 JSON 对象,其键为“time”,值为 UTC 中的当前时间,如下所示:
{ "time": "YYYY-MM-DD HH:MM:SS UTC" }
我进入主机中的文件管理器,添加了一个 funnel_webhooks 文件夹和一个名为 test 的文件。
我想我将内容类型更改为 JSON 而且,我想我已经知道如何在文件中创建 JSON 对象了。 我不知道如何做这部分: X-Clickfunnels-Webhook-Delivery-Id 作为 URL 和负载的 MD5。
这个织机视频将显示我目前所处的过程。
https://www.loom.com/share/1c9be96014b8413a8c9ba54f56dd42a8
任何支持将不胜感激!
其实比你想象的要简单得多。他们只是想通过从您放置在服务器文件夹中的任何文件获取 200 响应来验证您是否拥有该域。
只要您使用这个经过验证的域名,您以后的所有 Webhooks 都可以正常工作。
他们的文档很糟糕。
这是我的快速测试路线:
app.post("/test", async (req: express.Request, res: express.Response) => {
const currentTime = new Date().toISOString();
console.log(req.body); // This prints the contact/purchase object
const status = 200;
return res.status(status).json({
text: "[SUCCESS]: text successful",
ok: status < 300,
data: currentTime
});
});
我的端点是
https://us-central1-{SERVER_NAME}.cloudfunctions.net/funnel_webhooks/test
,其中 test
可以是您想要继续的任何其他端点,但 funnel_webhooks
是端点条目的必需部分。
让我试试吧!
您现在所做的只是创建一个 JSON 文件,该文件不会从 clickfunnel 获取 webhook 事件。
如果您的服务器与 PHP 兼容,请首先创建 PHP 文件。 只需在其中编写此代码并尝试一下即可。
<?php
//set the headers.
header("Content-Type: application/json;");
header("X-Clickfunnels-Webhook-Delivery-Id : MD5 of CONTENTS HERE");
//check if there is input data.
if ($json = json_decode(file_get_contents("php://input"), true)) {
//print and set the data as variable
print_r($json);
$data = $json;
}else{
//try getting the POST data.
print_r($_POST);
$data = $_POST;
}
//set the response as OK - 200
http_response_code(200); //response code for OK.
echo json_encode(array("status" => 'OK', "code" => 1, "payload" => $data));
//save the data as a file to check the information that was sent by the webhook.
$file = 'webhook_contents.txt';
$current = file_get_contents($file);
$current .= date("Y-m-d h:i:s").json_encode($data);
file_put_contents($file, $current);
// From here, it all depends on what you want to do with the webhook event data.
?>
此代码应该为您提供标头以获取 JSON 有效负载,并回显所述有效负载的响应。 同时,它应该创建一个名为“webhook_contents.txt”的文件,您应该能够在其中读取 webhook 事件负载。
如果有效请告诉我!