-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
94 lines (77 loc) · 2.83 KB
/
index.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
//set API key
$api_key = 'YourIDXBrokerAPIKey';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.idxbroker.com/clients/featured",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
'accesskey: '.$api_key,
'apiversion: 1.4.0',
'cache-control: no-cache',
'content-type: application/x-www-form-urlencoded',
'outputtype: json',
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
//get the account domain ONLY if using custom subdomain
$listings = json_decode($response, true);
foreach($listings as $k => $l) {
$link = $l[fullDetailsURL];
$titelProtocol = explode("/", $link);
$titleRoot = explode(".", $link);
$titleExtention = explode("/", $titleRoot[2]);
$titleLink = $titelProtocol[0].'://'.$titleRoot[1].'.'.$titleExtention[0];
break;
}
// Send the headers for XML
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<listings>
<title>'.$titleLink.' Feed</title>
<link rel="self" href="'.$titleLink.'"/>';
//create listings from API call
foreach ($listings as $key => $value) {
if($value[idxPropType] = 'Single Family' || $value[address] !== ''){
echo '<listing>
<home_listing_id>'.$value[listingID].'</home_listing_id>
<name>'.$value[address].'</name>
<availability>for_sale</availability>
<description>'.addslashes(htmlentities($value[remarksConcat])).'</description>
<address format="simple">
<component name="addr1">'.$value[streetNumber].' '.$value[streetDirection].' '.$value[streetName].'</component>
<component name="city">'.$value[cityName].'</component>
<component name="region">'.$value[state].'</component>
<component name="country">United States</component>
<component name="postal_code">'.$value[zipcode].'</component>
</address>
<latitude>'.$value[latitude].'</latitude>
<longitude>'.$value[longitude].'</longitude>
<image>
<url>'.$value[image][0][url].'</url>
</image>
<listing_type>for_sale_by_agent</listing_type>
<num_baths>'.$value[totalBaths].'</num_baths>
<num_beds>'.$value[bedrooms].'</num_beds>
<num_units>1</num_units>
<price>'.$value[price].' USD</price>
<property_type>house</property_type>
<url>'.$value[fullDetailsURL].'</url>
</listing>';
}
}
echo '</listings>';
}
?>