I'm trying to set up a webhook in Asana to send me event updates for a particular project. I am pretty novice so keep that in mind when reading and answering. My first post on here so go easy on me. Here's my code I am running.
asanawebhook.php page:
$headers = getallheaders();
$secret_token = $headers['X-Hook-Secret'];
header('X-Hook-Secret: ' . $secret_token);
header("HTTP/1.1 200 OK");
my curl request to create the webhook:
$apikey = "mykey"; // Your API key
$taskid = "resourceid";
exec( 'curl \
-H "Authorization: Bearer '.$apikey.'" \
-H "Content-Type: application/x-www-form-urlencoded" \
-X POST https://app.asana.com/api/1.0/webhooks \
-d "resource='.$taskid.'" \
-d "target=https://mywebsite.com/folders/asanawebhook.php"', $return);
print_r($return);
This has been getting me this error printed on my page.
Array ( [0] => {"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"}]} )
If I can get that to return a success message of some kind, I assume I can parse the data and then do a curl request back to Asana to get the full payload. Thanks in advance.
After carefully researching and polling Asana for help, I have determined that it was an SSL related problem for me. The code works great and allows the handshake to take place and sets up the webhook. What I didn't realize was that though I had an SSL cert I did not have it set up. Make sure SSL is configured correctly for the domain that the webhook target is going to.