How to integrate PHP website with NightsBridge : Integration and Price API Tutorial

The Right Software > Blog > Laravel > How to integrate PHP website with NightsBridge : Integration and Price API Tutorial
integrate PHP website with NightsBridge

How to integrate PHP website with NightsBridge : Integration and Price API Tutorial

NightsBridge based in South Africa is Africa’s most popular property management and real time booking system. Using NightsBridge, one can easily find and book any type of accommodation online, such as,

  • Bread and Breakfast (B&B)
  • Guest houses
  • Game lodges
  • Boutique halls
  • Self catering
  • Apartments
  • And more.

 

The Right Software are a web and mobile app development company and we provide third-party API integration services to South African web and app development clients. We recently had to use NightsBridge platform and API integration with PHP Laravel framework.

In this article, we’ll discuss how to

  • Setup NightsBridge booking system as an Affiliate Agency
  • Getting NightsBridge properties
  • Sending affiliate traffic back to NightsBridge through white label
  • Update your website using NightsBridge API calls

 

NightsBridge website tutorial and API integration

How does NightsBridge work?

NightsBridge provides an online portal on their website where property owners and managers can register their properties, accommodation types and prices. After property addition, NightsBridge provides the public page for each property which the owners can share over social media and public to garner NightsBridge bookings.

All NightsBridge affiliates have an ID called NBID and properties have an ID called BBID.

Following are the necessary steps which must be followed for NightsBridge integration into your own website.

 

Create NightsBridge Affiliate Account

To use NightsBridge properties in your website, first, you need to create an account with NightsBridge. When you create an account and login, NightsBridge will provide you a back office (an interface) where you will be able to manage all your properties.

Property owners can approach Affiliate site owners to request listing their properties on third-party websites. For that, they send a request to affiliates to add their website.

Affiliate can activate the property by assigning your internal code which will move it into the active property list.

 

Listing NightsBridge properties on your own website

To show NightsBridge properties on Affiliate websites, there is currently no API to bring all approved properties and you have to add properties manually through the database or run a web scraping script. We created a custom Laravel website with back office to handle properties on our website.

While listing NightsBridge property on your own website, make sure that you save NightsBridge property ID called bbid in your database.

After listing properties from NightsBridge, you have to send traffic back to the NightsBridge for conversion and also make updates to your PHP website. Here we discuss both.

 

banner hire laravel framework development services

 

NightsBridge Partial White Label Solution

Partial white label is when you an affiliate sends traffic to the NightsBridge property listing but the NightsBridge property page shows affiliate logo for increased branding. This is the method to send users to NightsBridge for booking properties.

Using NightsBridge partial white label, you can create link (as given below) to individual properties on NightsBridge where online bookings can be made.

https://www.NightsBridge.co.za/bridge/book?bbid=xxxxx&nbid=xxx

Where “bbid” is NightsBridge property ID which is unique for each property while nbid is your NightsBridge agency code for affiliates, that was emailed to you once you create account with NightsBridge.

Note that it’s very important to open this link in a new browser window instead of iFrame so that the security certificate is enabled. For example,

<a href=”https://www.NightsBridge.co.za/bridge/book?bbid=xxxxx&nbid=xxx” target=”_blank”>Book now</a>

 

Along with sending traffic to NightsBridge, there are some API calls available that you can use to update properties on Affiliate side.

 

NightsBridge Availability Search API

NightsBridge also provides Webservice API for searching NightsBridge database for property availability. You will pass property’s bbid and start and end dates in the API call.

The API in response will return property details showing whether property is available for booking on the specified dates or not.

The NightsBridge is offered in both JSON as well as XML format.

Json Format

1
2
3
4
5
6
7
{
    messagename: “AvailRQ”,
    credentials: { nbid: 123, password: “xxx” },
    bblist: { bbid: [10002, 10003, 10140] },
    startdate: “2017-10-03”,
    enddate: “2017-10-05”
}

 

Xml Format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<NightsBridge>
    <messagename>AvailRQ</messagename>
    <credentials>
        <nbid>xxx</nbid>
        <password>xxx</password>
    </credentials>
    <bblist>
        <bbid>xxxxx</bbid>
        <bbid>xxxxx</bbid>
        <bbid>xxxxx</bbid>
    </bblist>
    <startdate>2017-10-03</startdate>
    <enddate>2017-10-05</enddate>
</NightsBridge>

 

messagename “availRQ” is Availabilty Request API. Where nbid and password stands for your NightsBridge agency code and password respectively. While bbid’s stands for NightsBridge properties id’s.

This API needs to run once a day at least and also on each search just in case.

 

NightsBridge From Price API

The From Price API call is used to import the lowest prices for properties (multiple at a time). Like NightsBridge Availability Search API, From Price API is also provided in both JSON as well as XML format.

JSON Format

1
2
3
4
5
6
7
8
9
10
11
{
    "messagename": "PriceFromRQ",
    "credentials": {
        "nbid": 123,
        "password": "xxx"
    },
    "bblist": {
        "bbid": [15555, 10000, 10005]
    },
    "ratedate": "2015-05-10"
}

 

XML Format

1
2
3
4
5
6
7
8
9
10
11
12
13
<NightsBridge>
    <messagename>PriceFromRQ</messagename>
    <credentials>
       <nbid>123</nbid>
       <password>xxx</password>
    </credentials>
    <bblist>
        <bbid>15555</bbid>
        <bbid>10000</bbid>
        <bbid>10005</bbid>
    </bblist>
    <ratedate>2015-05-10</ratedate>
</NightsBridge>

 

In order to update prices in your database, you need to call this API at least once a day.

 

Sample Code

Here’s the sample PHP Code with Curl calls  to interact with the NightsBridge APIs discussed above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$nightsbridge_from_price_update_request = '{
    "messagename": "PriceFromRQ",
    "credentials": {
        "nbid": xxx,
        "password": "xxx"
    },
    "bblist": {
        "bbid": [10002, 10003, 10140]
    },
    "ratedate": "'.date('Y-m-d').'"
}';
 
$url = 'http://www.nightsbridge.co.za/bridge/jsonapi/4.0';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $nightsbridge_from_price_update_request);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt( $ch, CURLOPT_HEADER, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
if (curl_exec($ch) === FALSE) {
    die("Curl error: " . curl_error($ch));
}
 
$response = curl_exec( $ch );
$response = json_decode($response, true);

 

Following this tutorial, you can set up an affiliate website with NightsBridge booking system and API Integration. Contact us if you want to setup an Agency website with integration with NightsBridge properties and TripAdvisor reviews.

Pingback

Categories

Free Consultation





Please leave this field empty.

Contact Details

Office # 12,
3rd floor, MB City Mall
I-8 Markaz,
Islamabad, Pakistan.
+92-51-493-8304
hello@therightsw.com

Start a Project with The Right Software