尝试创建webhook时出错

时间:2016-08-31 13:08:13

标签: php asana asana-api

我尝试在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错误请求)

我通过邮递员向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);

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

1 个答案:

答案 0 :(得分:0)

根据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参数