Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. $url_api = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/";
  2. $api_key = "XXX"; // Not shown here
  3. $data = array('apiKey' => $api_key, 'country' => 'DE', 'currency' => 'EUR',
  4. 'locale' => 'de-DE', 'originplace' => 'HAM', 'destinationplace' => 'AMS', 'cabinclass' => 'economy', 'outbounddate' => '2017-01-27',
  5. 'inbounddate' => '2017-01-30' , 'locationschema' => 'Iata', 'groupPricing' => true);
  6.  
  7.  
  8. $httpdata = http_build_query($data);
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_URL, $url_api);
  11. curl_setopt($ch, CURLOPT_POST, true);
  12. curl_setopt($ch, CURLOPT_POSTFIELDS, $httpdata);
  13. curl_setopt($ch, CURLOPT_HEADER, true);
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'));
  15. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  17. curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  18. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
  19.  
  20. $response = curl_exec($ch);
  21. curl_close($ch);
  22.  
  23. $headers = get_headers_from_curl_response($response);
  24.  
  25. $url = $headers['Location']."?apiKey=".$api_key."&stops=0";
  26.  
  27. echo $url;
  28. return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement