QPX Express API - List of flights

0

I'm trying to use the QPX Express API to fetch list of flights, in the documentation I have how to pass the arguments, but I do not know how to use, for example:

Documentation:

  

The simplest way to try out this API is to send it to POST request with curl. For example, create a file named request.json with the following content (replace each> instance of YYYY-MM-DD with a date, which can be up to a year in the future.):

JSON:

{
  "request": {
    "passengers": {
      "adultCount": 1
    },
    "slice": [
      {
        "origin": "BOS",
        "destination": "LAX",
        "date": "YYYY-MM-DD"
      },
      {
        "origin": "LAX",
        "destination": "BOS",
        "date": "YYYY-MM-DD"
      }
    ]
  }
}

The documentation says this:

  

Then execute the following command from within the same directory as the above> request.json file. (As explained in Prerequisites, you must first obtain an API key.)

     

curl -d @ request.json --header "Content-Type: application / json" link

Where to run this code?

    
asked by anonymous 22.01.2015 / 16:46

2 answers

1

SOLUTION

I got a lot of research after getting the voip list using qpxExpress

<?php 

$url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=SUA-API-KEY";
$data_string = '{
                  "request": {
                    "passengers": {
                      "adultCount": 1
                    },
                    "slice": [
                      {
                        "origin": "MCO",
                        "destination": "GRU",
                        "date": "2015-01-23"
                      }
                    ],
                    "solutions": 2
                  }
                }';                                                                            
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   

$result = curl_exec($ch); // resultado!!!!
?>

Thank you!

    
23.01.2015 / 19:04
0

Basically to test QPX Express API using curl you should follow these steps:

  • Create a JSON file named request.json with the content that you put in the question and save it to a place you remember later, remembering that the documentation asks you to change the date:
  • >

    In my case I put the date of departure for (January 20, 2015) and the date of return to (January 27, 2015)

  • Access via terminal/prompt where you saved the created file and run the command:
  •   

    curl -d @ request.json --header "Content-Type: application / json"    link

  • In response you will see in the terminal a JSON code with a lot of information about the flight, follows the API response:
  • Considerations:

    • YoucangetanAPIKeybyfollowingthistutorialonthe API .

    • Another way to test the API (without using API Key and without using curl) is by visiting DEMO that the API makes available .

    22.01.2015 / 20:13