We told you already how you can use zapier.com to connect Riddle to a whole set of tools like Google Sheets or salesforce.com in this post.

Now we are going to get your inner geek going at full speed and show you how to write your own webhook with just a few lines of PHP

To get started, it would be good if you have:

  • a good understanding of PHP
  • a bit of knowledge about JSON
  • your own server or a cool place where you can upload a PHP file that is reachable on the web
  • a Riddle Pro account or a free 14 day trial account with all features unlocked

Get started by creating a Riddle with a lead gen form and go to the integrations tab on the create screen.

Here you paste the URL of the page where your personal webhook code will run. Something like:

http://mydomain.com/riddle_is_awesome.php

Save and publish the Riddle and run through it one time, filling out the form to make sure it all works.

The create a php file with this tiny bit of code:



<?php
 
 $data = file_get_contents('php://input');
 $req_dump = print_r(json_decode($data), true);
 file_put_contents( 'request.log', $req_dump );

As you can see in the image on the right, Riddle sends you all data as a nicely formatted JSON string via POST. All you need to do is grab that POST JSON and process it as you like.

The sky is the limit of where you can go from here. You can write your own code to push the Riddle data to a CRM of your choice, write it all into your own database and build your own personal Riddle dashboard and much more.

Need help or custom code? Reach out to us via hello@riddle.com and we will help you (even though we will need to charge for our time when we do custom code).

The code above is just a starting point. Use this improved PHP code to process the data sent through to your hook if you know your way around PHP (as you will see below, this code is just a starting point. It does not really do anything with the data yet)

<?php

    header('Access-Control-Allow-Origin: *'); 

    $data = file_get_contents('php://input');

    echo '<pre>';

    print_r(json_decode($data));

    echo '</pre>';

?>

Don't know where to start coding your own Riddle script?

No worries, we got you covered.

Check out our Github repository for cool sample scripts.

This is the output in the request.log file generated by the code on the left