Post authentication headers from webhook?

  • 26 April 2017
  • 1 reply
  • 21 views

I wrote a module to post JSON data to ReServe Cloud from our Drupal websites, and now people want me to connect from unbounce landing pages to ReServe.

The problem is, getting the data into Reserve requires authentication, so I do the interaction with cURL like so:

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL,$url);

// Authorization
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
                                           'Content-Length: ' . strlen($data_string)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$server_output = curl_exec ($ch);
curl_close ($ch);

It looks to me like all I can do with WebHooks is send to a url that doesn’t require authentication. Is this correct, or is there some way to send a username/password?


1 reply

Userlevel 7
Badge +3

Hi @dalemgreer,

Yes, currently you can only send the form data to the webhook URL. You can’t add any authentication from within Unbounce.

However, you can write your own webhook script that would accept the form data, add any authentication you need and send it to its final destination.

Best,
Hristian

Reply