Woobox is great for slapping up a quick promo based on one of their templates. But what if you want to get this data into another database or mailing system that isn't supported natively by Woobox? Well you're in luck as this is your guide to getting your custom Woobox integration up and running.
Woobox has a Webhook function which allows you to post data to a location of your choice. I set one of these up recently and thought I would expand a bit on their documentation with some code examples.
Create your custom Woobox integration endpoint URL
This endpoint URL/link will receive the data from Woobox and allow you to process it.
The tricky part here is the authentication. The first time Woobox talks to your endpoint it will send only a unique code. This code needs to be used in all future responses. The docs skim over this and show a sample which doesn't work... but the easiest way I found to handle this is to save the code and then copy / paste it out to be used later.
1) Get the Authentication code
Create a PHP script and add only this line to it:
file_put_contents('data.txt', $_POST, FILE_APPEND | LOCK_EX);
Upload the script to your web server and visit:
admin.woobox.com/manage/businesses/integration
Add the link to your script here and hit save. Woobox will send a unique code directly to the data.txt file. Copy that code and store it somewhere so we can use this later.
2) Create the rest of your script
Now we have the auth code we can add it to our processing script which will receive the data and do the real work. Below are all the lines of code you will need to do this.
header("realtimeapi: 9Zuk6"); //Replace 9Zuk6 with your own code saved in data.txt
if(!isset($_POST['entries'])){
die('No data.');
}
$data_array = json_decode($_POST['entries'], true); // Convert the JSON data to a PHP array.
foreach($data_array as $entry){
echo $entry['email'];
var_dump($entry); //Checkout the data and process acordingly
}
The code above receives the data and then process each entry in the for each loop. Here you can start coding your own integration and insert it into any other system you like.
To speed up testing use PostMan for Google Chrome. Below are the settings you will need. Swap out the URL for your own etc.
Here is some JSON data you can use. Or generate your own by doing a few submissions and storing the response.
[{"email":"ralph@test.com","createdate":"2016-12-15 20:41:11","from_liked_pageid":null,"source":"direct","ipaddress":"202.1.1.1","entry_url":"https://admin.woobox.com/manage/offers/entries/123-1/wqaZEZyzi8pJKg4u6AQtXBBIILiF7XzKBD5hWjm54xQbGQK5Th90k%2FTwQcAiegrlddUpDgzmlzGh1MCF9RsrAfpQ%3D%3D","shareurl":"http://woobox.com/3243/3433","picked":"0","custom_4_first":"Ralph","custom_4_last":"Vugts","custom_7":"04666666666","custom_5":"sydne","custom_8":"on","custom_9":"on","quizquestion_1 position_1":"choice_6","quizquestion_2 position_2":"choice_6","quizquestion_3 position_3":"choice_3","quizquestion_4 position_4":"choice_3","quiz_result":"Result_3","fullname":"Ralph Vugts","id":"3243d"},{"email":"michelle@test.com","createdate":"2016-12-15 20:43:34","from_liked_pageid":null,"source":"direct","ipaddress":"202.1.1.1","entry_url":"https://admin.woobox.com/manage/offers/entries/sdf333-1/1234X%2Bxk1ahmTgkJShlzQDpdDMynC9533UQgV1OhgJkFJVDz%2B2FfP5Q%2BkajJAmTRc0aXTsHU2%2FMNw%3D%3D","shareurl":"http://woobox.com/33333/2","picked":"0","custom_4_first":"Michelle","custom_4_last":"okee","custom_7":"045454544","custom_5":"Syd","custom_8":"on","quizquestion_1 position_1":"choice_2","quizquestion_2 position_2":"choice_2","quizquestion_3 position_3":"choice_2","quizquestion_4 position_4":"choice_2","quiz_result":"Result_1","fullname":"Michelle okee","id":"dfsdfds"},{"email":"asmin@test.com","createdate":"2016-12-15 20:46:58","from_liked_pageid":null,"source":"direct","ipaddress":"202.1.1.12","entry_url":"https://admin.woobox.com/manage/offers/entries/1333-1/t7FVIp1TxkhS8aPJrHjfQK5AKwtI4i9dfdfZUhHRhfpUu96zbkw1YWyhx3Yp9EF1E%2F%2BDJLEPa51X0nVR8fHXqwOXGg%3D%3D","shareurl":"http://woobox.com/yh6k4x/icjp6y","picked":"0","custom_4_first":"Asmin","custom_4_last":"Smith","custom_7":"045104489","custom_5":"Sydney","custom_8":"on","quizquestion_1 position_1":"choice_6","quizquestion_2 position_2":"choice_3","quizquestion_3 position_3":"choice_3","quizquestion_4 position_4":"choice_1","quiz_result":"Result_5","fullname":"Asmin white","id":"3fdsfd"}]
Use the settings above and post this to your script to quickly test it.
Once you are happy with your script upload the final version to your web server and add your URL here again:
admin.woobox.com/manage/businesses/integration
And hit save. It will check for the authentication and permanently store your URL for use with your promotions.
Activate Realtime Export for your Woobox Promo
Once your promo has been setup you still need to activate the real time export for each promo. Simply click on manage and then find the realtime exports on the sidebar and activate the Webhook you have just created.
Every time someone now completes a Woobox promo, the data will be pushed to your script and processed to your liking. This can be very useful for marketing automation... or just keeping all your data in one place.
Need help setting up your own custom Woobox integration? Contact us here - we'd love to hear from you.