-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathean.php
71 lines (60 loc) · 2.12 KB
/
ean.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class EAN {
public $base_url = "http://api.ean.com/";
// public $secure_base_url = "https://api.ean.com/";
public $consumerKey;
public $clientSecret;
public $useragent = "Jay Zalowitz's EAN API PHP Class";
function __construct($consumerKey, $clientSecret) {
$this->consumerKey = $consumerKey;
$this->clientSecret = $clientSecret;
}
function discoverHotel($address = null, $hotelId = null, $affinity = null, $maxResults = '200',$offset = null) {
// Docs: http://dev.ean.com/docs/innovation-labs/expedia/travel-search/hotel-search/
// address string A geo codeable address. e.g. 'seattle'
// hotelId integer hotel identifier
// poiId integer Point of interest identifier
// regionId integer Region identifier
$profileApiLocation = $this->base_url .'expe/affinity/v1/get/hotels?userId=ama';
$profileApiLocation .= '&format=json';
$profileApiLocation .= '&apiKey='.$this->consumerKey;
if ($address){
$profileApiLocation .= '&address='.urlencode($address);
}
if ($affinity){
$profileApiLocation .= '&affinity='.urlencode($affinity);
}
if ($hotelId){
$profileApiLocation .= '&hotelId='.urlencode($hotelId);
}
if ($maxResults){
$profileApiLocation .= '&maxResults='.urlencode($maxResults);
}
if ($offset){
$profileApiLocation .= '&offset='.urlencode($offset);
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $profileApiLocation,
CURLOPT_USERAGENT => $this->useragent
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
function ToExpedia($id) {
$apiLocation = 'http://nswaytortlywhomeaterempl:[email protected]/expe_prop/_design/ean/_view/expeean?key='.$id;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $apiLocation,
CURLOPT_USERAGENT => $this->useragent
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response, 1);
$response = $response['rows']['0']['value']['id'];
return $response;
}
}