【问题标题】:Error trying to create webhook尝试创建 webhook 时出错
【发布时间】:2016-08-31 13:08:13
【问题描述】:

我尝试为 Asana 中的一项任务创建一个 webhook,但我得到的唯一响应是:

{
  "errors": [
    {
      "message": "Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL",
      "help": "For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"
    }
  ]
}

(状态:400 错误请求)

我正在通过 Postman 向 https://app.asana.com/api/1.0/webhooks 发送一个 POST 请求,内容如下:

{
  "data": 
    {
      "resource": 123456789012345,
      "target": "https://example.com/asana.php"
    }
}

asana.php 看起来像这样:

$headers = getallheaders();
$secret_token = $headers['X-Hook-Secret'];
header('X-Hook-Secret: ' . $secret_token);

我做错了什么?我错过了什么吗?

【问题讨论】:

    标签: php asana asana-api


    【解决方案1】:

    根据 Asana API 参考 (https://asana.com/developers/api-reference/webhooks),

    目标必须以 200 OK 和匹配的 X-Hook-Secret 标头进行响应,以确认该 webhook 订阅确实是预期的。

    当您发送标头时,您知道正在发送什么响应代码吗?也许您可能想看看http://php.net/manual/en/function.header.php 中的$http_response_code 参数

    【讨论】:

    • 我用 Postman 测试了脚本,它响应 200 OK 和 X-Hook-Secret。在另一台网络服务器上测试后(它工作!),似乎我使用的那个有什么东西,所以没有任何与代码相关的......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-26
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多