How to use webhook ?

edited April 2018 in Developers
Hi their,

I've tried to use webhooks to send SMS with twilio to present the Alphanumeric ID instead of a mobile number that doesn't erally exist.
I'm able to send correctly a SMS with webhook but not dynamicly. In other hands I am not able to retreive the data that where posted by checkfront backend.

Could you please just help to read data in PHP posted by checkfront ?

I've tried XML, JSON and x-form...

so my last code is :
<?
$startdate= $_GET["start_date"];
$sku = $_GET["sku"];
$status = $_GET["status"];
$textSMS= $startdate . "-" . $sku . "-" .$status;


require_once 'vendor/autoload.php';
$sid = "bla bla"; // Your Account SID from www.twilio.com/console
$token = "blabla"; // Your Auth Token from www.twilio.com/console

$client = new Twilio\Rest\Client($sid, $token);
$message = $client->messages->create(
  'field to get from checkfront', // Text this number
  array(
    'MessagingServiceSid' => "bla bla", // From a valid Twilio number
    'body' => $textSMS));

print $message->sid;

?>

If I specify my mobile number I receive : "---"...

thank you for helping.
Florent.

Comments

  • Hello,

    Thank you for using our forums!

    In order to correctly access the data in the response, it may help to see how it is actually formatted. You could try using the developer console to see the full response of your query. 

    To access the console, go to Manage > Developer > Console. Try typing in a query, such as 'booking/{booking_ID}' (where '{booking_ID}' is the ID of one of your bookings).

    Doing this will let you see how the response is formatted and therefore, how to access the data. For example, most of the information you need will be in the 'booking' array. So, your code should look more like this:

    $startdate = $_GET["booking"]["start_date"];

    I hope this helps and let me know if you have any more questions!

    All the best,
    Chase - Checkfront Support Team
  • This information is good for me.
  • edited January 11

    @Florent looking to review the data sent from Checkfront before written out a bunch of code? Try using a webhook parsing service, I have been using https://webhook.site along with a few others to model the data I'd like to use. (example webhook data below)

    When a booking status changes it sounds like you would like to review the items node and compare between old and new.

    https://gist.github.com/gegere/8b839037b54131565391e3cfe7e0990c


    Helping build online services to give businesses in the travel & hospitality space the tools to succeed
    Web Dev | HTMLgraphic.com

  • To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook. Alternatively, you can choose to build and manage a webhook through the Webhooks API. Webhooks require a few configuration options before you can make use of them.
Sign In or Register to comment.