How to create qpx express filight search api in google in php

 

Go to

1) https://developers.google.com/qpx-express/

2) Login or create account

3) Then create a project. to create project go to https://developers.google.com/qpx-express/v1/prereqs#project

4) Then go to Google API Console. to go Google API Console please go to https://console.developers.google.com/project?pli=1

 

5) Create project ->type project name

6) Go to dashboard and enbale APIS AND SERVICES

7) Find the api QPX Express in the search box and enbale

now use the following code to get the result

<?php
$url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=<Your Api Key>"

$postData = array(
"request" => array(
"passengers" => array(
"adultCount" => 1
),
"slice" => array(
array(
"origin" => "IXB",
"destination" => "DEL",
"date" => "2017-10-24"
),
array(
"origin" => "DEL",
"destination" => "IXB",
"date" => "2017-10-24"
)
)
)
);

 

$curlConnection = curl_init();

curl_setopt($curlConnection, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($curlConnection, CURLOPT_URL, $url);
curl_setopt($curlConnection, CURLOPT_POST, TRUE);

curl_setopt($curlConnection, CURLOPT_POSTFIELDS, json_encode($postData));
curl_setopt($curlConnection, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlConnection, CURLOPT_SSL_VERIFYPEER, FALSE);

$results = curl_exec($curlConnection);
print_r($results);

 

Leave comment

Your email address will not be published. Required fields are marked with *.