Coder Social home page Coder Social logo

skyscanner-php's Introduction

Unofficial PHP SDK for Skyscanner API

Latest Version on Packagist Software License Build Status Total Downloads

This is an unofficial PHP SDK for the Skyscanner API to support Flights, Car Hire, Hotels, Localisation, and Places services.

Currently, all of the services are implemented. Also tested all off the services except the Hotels one since could not find any valid API keys, and had no luck with contacting anyone from Skyscanner.

Install

Via Composer

$ composer require ozdemirburak/skyscanner-php

For PHP 7.0 and below, use ~1.0 instead.

Usage

Please see the wiki for more detailed information about the methods and the parameters.

You can find a simple demonstration of how to use the methods below, or check the tests for more advanced examples.

Flights: Live Pricing

use OzdemirBurak\SkyScanner\Travel\Flights\LivePricing;

$pricing = new LivePricing($apiKey = 'your-api-key');
$pricing->setParameters([
    'adults' => 1,
    'country' => 'GB',
    'currency' => 'GBP',
    'destinationPlace' => 'IST',
    'locale' => 'en-GB',
    'originPlace' => 'LHR',
    'outboundDate' => date('Y-m-d', strtotime('+1 week')),
    'stops' => 0
]);
$flights = $pricing->getFlights($onlyFirstAgentPerItinerary = true);

Flights: BrowseCache

use OzdemirBurak\SkyScanner\Travel\Flights\BrowseCache;

$cache = new BrowseCache($apiKey = 'your-api-key');
$cache->setParameters([
    'country' => 'TR',
    'currency' => 'TRY',
    'destinationPlace' => 'IST',
    'locale' => 'tr-TR',
    'originPlace' => 'LHR',
    'outboundPartialDate' => date('Y-m-d', strtotime('+1 week')),
]);
$quotes = $cache->getPrices()['Quotes'];

Car Hire: Live Pricing

use OzdemirBurak\SkyScanner\Travel\CarHire\LivePricing;

$pricing = new LivePricing($apiKey = 'your-api-key');
$pricing->setParameters([
    'country' => 'GB',
    'currency' => 'GBP',
    'dropoffplace' => 'ADB',
    'dropoffdatetime' => date('Y-m-d\TH:i', strtotime('+2 week')),
    'locale' => 'en-GB',
    'pickupplace' => 'IST',
    'pickupdatetime' => date('Y-m-d\TH:i', strtotime('+1 week')),
    'driverage' => 21
]);
$cars = $pricing->getCars();

Hotels: Live Pricing

use OzdemirBurak\SkyScanner\Travel\Hotels\LivePricing;

$pricing = new LivePricing($apiKey = 'your-api-key');
$pricing->setParameters([
    'country'       => 'TR',
    'currency'      => 'TRY',
    'entity_id'     => 27544008,
    'checkin_date'  => date('Y-m-d', strtotime('+1 week')),
    'checkout_date' => date('Y-m-d', strtotime('+2 week')),
    'locale'        => 'tr-TR'
]);
$hotels = $pricing->getHotels();

Localisation: Currency

use OzdemirBurak\SkyScanner\Localisation\Currency;

$currency = new Currency($apiKey = 'your-api-key');
$currencies = $currency->get();

Localisation: Locale

use OzdemirBurak\SkyScanner\Localisation\Locale;

$locale = new Locale($apiKey = 'your-api-key');
$locales = $locale->get();

Localisation: Market

use OzdemirBurak\SkyScanner\Localisation\Market;

$market = new Market($apiKey = 'your-api-key'));
$market->setLocale('en-GB');
$countries = $market->get();

Places

use OzdemirBurak\SkyScanner\PlacesService;

$places = new PlacesService($apiKey = 'your-api-key');
$geoCatalog = $places->get();
$list = $places->getList('UK', 'GBP', 'en-GB', 'istanbul');
$information = $places->getInformation('UK', 'GBP', 'en-GB', 'CDG-sky');
$hotels = $places->getHotels('UK', 'EUR', 'en-GB', 'paris');

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

skyscanner-php's People

Contributors

jamesmills avatar ozdemirburak avatar t3hn0 avatar vincentv92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skyscanner-php's Issues

Places and stops not available in the result

Hi I am using your code for fetching results in my coding style. This is good and written in better way.
Please tell me how can I embed places and stops in the returning result.

Thanks

Undefined index: argv

Undefined index: argv

vendor/ozdemirburak/skyscanner-php/src/Traits/ConsoleTrait.php (114)

    private function isPrintable($force = true): bool
    {
        return !($force === false && strpos($_SERVER['argv'][0], 'phpunit') !== false);
    }

Might need to rewrite this as

return !($force === false && strpos(($_SERVER['argv'][0]) ?? null, 'phpunit') !== false);

about Flights Live Pricing

I'm getting that error: Rate limit has been exceeded: 0 PerMinute for PricingSession

What do youthink?

What about the paymnet?

In skyscanner doesn't explain about payment, can you explaind about the proccess to get live ticket until payment accept and ticket issue.

Thank you

Stops parameter

In LivePricing class there is a 'stop' parameter set as 0 by default. Based on API documentacion this param can be only 0 or 1, but if you don't want to get results depending on stops, you shouldn't send this param at all. You should set $stop property as null by default and do not return it in getOptionalPollingParameters() method if there is no value in it.

Guzzle 7 support

Hello!

First of all: Thank you for your awesome package! 🙂 It really makes using the skyscanner api a breeze.
I'm currently trying to install this package into a Laravel 9 project, which has a hard dependency on Guzzle 7. Therefor, I'm getting the following error whilst installing your package:

  Problem 1
    - Root composer.json requires ozdemirburak/skyscanner-php ^0.2.1 -> satisfiable by ozdemirburak/skyscanner-php[0.2.1].
    - ozdemirburak/skyscanner-php 0.2.1 requires guzzlehttp/guzzle ~6.0 -> found guzzlehttp/guzzle[6.0.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.2).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require ozdemirburak/skyscanner-php:*" to figure out if any version is installable, or "composer require ozdemirburak/skyscanner-php:^2.1" if you know which you need.

Are you planning on supporting guzzle 7 in the future?

is working

Hi... we are trying to use your API, but not work.
my code is:
require 'vendor/autoload.php';

use OzdemirBurak\SkyScanner\Travel\Flights\LivePricing;

$pricing = new LivePricing($apiKey = 'mr724683266549xxxxxxxxxxx', $country = 'GB', $currency = 'EUR', $locale = 'en-GB');
$pricing->setParameters([
'adults' => 1,
'destinationplace' => 'IST',
'originplace' => 'LHR',
'outbounddate' => '10/10/2016',
'stops' => 0
]);
$flights = $pricing->parseFlights($onlyCheapestAgentPerItinerary = true);

var_dump($flights);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.