function __construct($username, $password, $env, $campaignid) { if (!in_array($env, array('test', 'production'))) { $this->error('Environment "' . htmlentities($env) . '" is not valid. Only "production" and "test" are supported.'); } self::$username = $username; self::$password = $password; self::$env = $env; self::$campaignid = $campaignid; }
protected static function post($body) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, parent::api_url()); curl_setopt($ch, CURLOPT_USERAGENT, "EasytobookPHPClient v1.0"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, "request=" . urlencode($body)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); return $result; }
<?php // Require the functions require 'functions/easytobook_functions.php'; // Initialise the functions // Need to pass the username, password, environment and campaign id // I.E. new Easytobook ('username', 'password', 'test', 'campaign id') $d = new Easytobook('affiliate', 'affiliate', 'test', '1'); // Will get all available rooms in Edinburgh for new year echo "<br>Get Search Availability<br>"; $array = array('Cityid' => '2117', 'Startdate' => '2015-12-30', 'Enddate' => '2016-01-02', 'Rating' => '4', 'Noofpersons' => '2', 'Language' => 'en', 'Currency' => 'GBP'); print_r($d->SearchAvailability($array));