title: Need help creating a QPX Express request with Google APIs Client Library for PHP
body: <p>I am trying to do find the lowest prices for special flights and would like to use the <a href="https://developers.google.com/qpx-express/" rel="nofollow noreferrer">QPX Express API</a> provided by Google Developers. Since I am a PHP developer, I thought the <a href="https://github.com/google/google-api-php-client#google-apis-client-library-for-php" rel="nofollow noreferrer">Google APIs Client Library for PHP</a> is the method of choice for me.</p>
  
  <p>However, I get stuck when it comes to combinig the PHP API with the QPX Express API:</p>
  
  <p>Concerning QPX Express, I know I have to create a JSON object that has to be sent to the API, which can even easily be done by the Demo on <a href="https://qpx-express-demo.itasoftware.com/" rel="nofollow noreferrer">https://qpx-express-demo.itasoftware.com/</a> .</p>
  
  <p>Concerning the PHP API Client, I think I have to create a Client object and the QPX Express Service object, like so:</p>
  
  <pre><code>require_once 'Google/Client.php';
  require_once 'Google/Service/QPXExpress.php';
  $client = new Google_Client();
  $client-&gt;setApplicationName("Testing");
  $client-&gt;setDeveloperKey("MY_APP_KEY");
  $service = new Google_Service_QPXExpress($client);
  </code></pre>
  
  <p>(I have already created a new project and an API KEY in the Google Developers Console.)</p>
  
  <p>But then I do not know what to with it in order to send the JSON request and receive a JSON Response. I either did not find the correct resource, or I am lacking knowledge about RESTful APIs... Unfortunately, I did not find something like a tutorial for that special case (PHP API and QPX), and the <a href="https://github.com/google/google-api-php-client/blob/master/src/Google/Service/QPXExpress.php" rel="nofollow noreferrer">simple example</a> did not help much, neither did the QPX Express reference. So, I hope someone can put me on the right track... Thanks in advance!</p>
  
  <p><strong>UPDATE:</strong>
  With the help of the first answer by <a href="https://stackoverflow.com/questions/24587895/need-help-creating-a-qpx-express-request-with-google-apis-client-library-for-php/24588033#24588033">ämbi</a>, I came up with the following code, which results in a Fatal Error.</p>
  
  <p>The code:</p>
  
  <pre><code>require_once 'Client.php';
  require_once 'Service/QPXExpress.php';
  $client = new Google_Client();
  $client-&gt;setApplicationName("Testing");
  $client-&gt;setDeveloperKey("[myKey]");
  $service = new Google_Service_QPXExpress($client);
  $request = new Google_Service_QPXExpress_TripOptionsRequest();
  $request-&gt;setMaxPrice('EUR200');
  $searchRequest = new Google_Service_QPXExpress_TripsSearchRequest();
  $searchRequest-&gt;setRequest($request);
  $result = $service-&gt;trips-&gt;search($searchRequest);
  </code></pre>
  
  <p>The resulting error:</p>
  
  <pre><code>&lt;b&gt;Fatal error&lt;/b&gt;:  Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/qpxExpress/v1/trips/search?key=[myKey]: (500) Backend Error' in C:\dev\www\Google\Http\REST.php:79
  Stack trace:
  #0 C:\dev\www\Google\Http\REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request))
  #1 C:\dev\www\Google\Client.php(499): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
  #2 C:\dev\www\Google\Service\Resource.php(195): Google_Client-&amp;gt;execute(Object(Google_Http_Request))
  #3 C:\dev\www\Google\Service\QPXExpress.php(91): Google_Service_Resource-&amp;gt;call('search', Array, 'Google_Service_...')
  #4 C:\dev\www\fluege.php(13): Google_Service_QPXExpress_Trips_Resource-&amp;gt;search(Object(Google_Service_QPXExpress_TripsSearchRequest))
  #5 {main}
    thrown in &lt;b&gt;C:\dev\www\Google\Http\REST.php&lt;/b&gt; on line &lt;b&gt;79&lt;/b&gt;
  </code></pre>
  
  <p>Does the mistake catch anyone's eye?</p>