I'm having a bit of trouble testing a webhook. They are registering OK: I can use the list webhooks api to see them fine. (I'm using php wrapper...)
When I call the test api (just in a browser), I get a 200 OK, and my script receiving them at the moment just emails me the POST data... of which there is none. It's just an empty array.
My list is empty at the moment - but I don't think it's made any difference whether there's some members or not.
Any clues? What am I missing?
The data returned by the webhooks 'test' route won't have any values from your list, so you're correct: no need for real subscribers.
You can check that your webhooks are configured the way you want by temporarily pointing them at postbin.org, which records all POST data sent to a given route. Once you've captured some data, you could use that to test that your email-POST script is interpreting it correctly.
If you don't have any luck with that, perhaps paste us the relevant bits of your code so we can see what's going wrong.
As a point of reference, we've included sample code for receiving webhook notifications in the PHP wrapper. Since the webhook data is not a normal form POST, the $_POST superglobal is not populated by the PHP environment prior to script execution.
Hi Toby and James
I'm using Zend Framework, and you're right, $request->getPost() (and $_POST) were empty. However, $request->getRawBody() contains the data.
By the way, I think there's a typo in the webhook docs. On the subscriber de-activate bit, the sample request has Type: "Subscribe" but I think it should be Type: "Deactivate"
it doesn't appear that there's anyway to tell the source of a webhook from the data being passed. This means that if my API call adds a subscriber, I get a 'Subscribe' POST message right back but have no easy way to detect the circularity. This adds considerably to the complexity of my implementation, but a 'Source' parameter in the POSTed data which related to the triggers in the API docs (i.e. 'Form' | 'Api' | 'FileImport' etc) would make it really easy. SignupIPAddress is almost there, but it seems only to come in manual updates that I make through createsend. The parameter's missing completely when I do API subscriptions. And it only appears to come on Subscribe hooks, not the others.
Any chance you could look to add this? Without it I'm not sure webhooks can work, really, it just feels all too fragile.
+1 for Matt's request in adding a source.
Even better, it should post some kind of secret token, otherwise this is an open gate for hackers!
It concerns me that the $_POST variable is empty... Should this be stated in the docs? Or is this PHP only issue?
I've added your vote for adding a source to the webhook calls.
As for $_POST not being filled in, this is to be expected. $_POST handles form data in the format of <key>=<value>&<key>=<value>&... in the body of the request. However, as described on http://www.campaignmonitor.com/api/webhooks/#whats_a_webhook we actually don't send data this way. Instead, we send the data to you using JSON, which would be very hard for $_POST to handle appropriately.
Hopefully this clears some questions up that you have, but let me know if anything is still unclear.
From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that drive real business results.Get started for free