我正在尝试使用cURL向Zapier webhook发送POST请求。
Zapier已经配置好了,如果我像这样输入它们的URL -- https://zapier.com/hooks/catch/n/abcd?email=foo@bar.com&guid=foobar 它将会接收到POST请求,但是当我尝试使用cURL做同样的事情时,它似乎没有接收到。
这是我使用cURL进行POST请求的代码 -->
当我运行它时,它显示成功,但 Zapier 没有收到它。
在 Zapier 的文档中,有人给出了一个正确的 cURL post 的示例,如下所示 -->
Zapier已经配置好了,如果我像这样输入它们的URL -- https://zapier.com/hooks/catch/n/abcd?email=foo@bar.com&guid=foobar 它将会接收到POST请求,但是当我尝试使用cURL做同样的事情时,它似乎没有接收到。
这是我使用cURL进行POST请求的代码 -->
<?php
// Initialize curl
$curl = curl_init();
// Configure curl options
$opts = array(
CURLOPT_URL => 'https://zapier.com/hooks/catch/n/abcd',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => 'guid='+ $_POST["guid"] + '&video_title=' + $_POST["video_title"] + '&email=' + $_POST["email"],
);
// Set curl options
curl_setopt_array($curl, $opts);
// Get the results
$result = curl_exec($curl);
// Close resource
curl_close($curl);
echo $result;
?>
当我运行它时,它显示成功,但 Zapier 没有收到它。
在 Zapier 的文档中,有人给出了一个正确的 cURL post 的示例,如下所示 -->
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST \
-d '{"first_name":"Bryan","last_name":"Helmig","age":27}' \
https://zapier.com/hooks/catch/n/Lx2RH/
我猜测在 PHP 文件中我漏掉了什么,非常感谢您的帮助!