Skip to main content

Getting Started with PHP

Preface​

In this guide, we will learn how to use BookingSync API using PHP language and our dedicated PHP lib.

We will here run get_rentals example. This example use oauth2 bookingsync php. PHP 5.4 is required here.

Requirements​

  1. Clone this repository into your web server. e.g: /var/www/

  2. Create a new Vhost

<VirtualHost *:80>
ServerName bsa-rest-php.dev

DocumentRoot /var/www/rest-request-php/examples/api-v3/
<Directory /var/www/rest-request-php/examples/api-v3/>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>

Create the application​

Applications that want to use the API need to be registered in the partner panel on BookingSync.com.

If you are not a partner yet, it's free to signup so join us :)

Click on New Application button

  • Name: Choose a name for your application. e.g: REST PHP
  • Admin url: Same as Redirect URI, opening the app from BookingSync admin dashboard will run the script.
  • Redirect URI: We want to run get_rentals example, so: https://bsa-rest-php.dev/get_rentals.php

On the right side, select Standalone and Private

Once your application is created, copy the Private App Access Code. Then go to the Admin panel > Apps and paste this code inside Install a Private App.

Using BookingSync API​

Open examples > api-v3 > get_rentals.php file.

Go to you Partner Panel and click on manage and copy/paste Client ID and Client Secret into this file. Same for redirectUri.

If you go now to https://bsa-rest-php.dev/get_rentals.php you should be able to see the result of this example.