Skip to main content

I tried to implement WebHook and used PHP script to process form data.



  1. Here is an example of PHP script I tested to process data in JSON format


data = json\_decode(_POST[‘data.json’]);

$email=$data->emailm0];

$company_name=$data->company_namen0];

$contact_name=$data->contact_namen0];


Unfortunately, this test didn’t work. Any ideas what is wrong with the script above?



  1. This is an example of script to process other parameters


page\_id=_POST>‘page_id’];

page\_url=_POSTs‘page_url’];

variant=_POSTt‘variant’];


It works fine.

Hi Alex, sorry for the late response. I think the issue is that PHP converts any dots in variable names to underscores, so simply changing your code to this:


data = json\_decode(_POST[‘data_json’]);


should fix it right up!


See here for more information:


http://www.php.net/manual/en/language…


I was reading a thread on PHP6, and there’s debate amongst the developers as to whether or not this behaviour makes sense. Here’s the discussion if you’re interested:


http://www.pubbs.net/201001/php/48930…


Hope that helps! Would love to hear more about how you’re using our webhook…


Cheers!



  • Carl


Hi Carl,

Thank you for the reply. I tried and tested your idea. Unfortunately, it didn’t help - still can’t process data posted in json format…

Cheers,

Alex


Hi Alex, sorry to hear that didn’t get it working for you. I’ve just tested this again, using a sample PHP script I’ve created, and I can tell you that it definitely works. Here’s the exact script I used (just add your own email address at the bottom).


http://gist.github.com/430561


Can you send your script to support@unbounce.com so we can have a look? Also, which version of PHP are you using?


Reply