-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.php
More file actions
16 lines (16 loc) · 792 Bytes
/
Copy pathquickstart.php
File metadata and controls
16 lines (16 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// DO NOT EDIT BY HAND — StayingAPI examples, generated by the export script. Edit the script + re-run.
// Quickstart: search vrbo stays. Run: php quickstart.php
$key = getenv("STAYINGAPI_KEY") ?: exit("Set STAYINGAPI_KEY=stay_...\n");
$q = http_build_query(["location" => "Split, HR", "platforms" => "vrbo", "limit" => 5]);
$ch = curl_init("https://api.stayingapi.com/v1/search?" . $q);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . $key],
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code !== 200) { fwrite(STDERR, "HTTP $code: $body\n"); exit(1); }
foreach (json_decode($body, true)["data"] as $s) {
echo $s["platform"] . " - " . $s["name"] . " - " . $s["price"] . "\n";
}