Skip to content

Instantly share code, notes, and snippets.

@zhelinskyy
Created March 16, 2017 19:52
Show Gist options
  • Save zhelinskyy/5d16258ee029e3691a8be6e8631d8655 to your computer and use it in GitHub Desktop.
Save zhelinskyy/5d16258ee029e3691a8be6e8631d8655 to your computer and use it in GitHub Desktop.
Curl
private function curl($url, $content) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->header);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
$server_output = curl_exec ($curl);
echo "\n".$server_output."\n";
$info = curl_getinfo($curl, CURLINFO_HEADER_OUT);
echo"<pre>";
print_r($info);
echo"</pre>";
$info = curl_getinfo($curl);
echo"<pre>";
print_r($info);
echo"\n";
curl_close ($curl);
/* if ($this->echo) {
header('Content-Type: application/json');
print_r(json_decode($server_output));
} else {
return $server_output;
}*/
}
function getCalendar($start_date, $end_date, $listingId) {
$url = "https://api.airbnb.com/v2/batch/?client_id=3092nxybyb0otqw18e8nh5nty&locale=en-US&currency=USD";
//$url = "https://api.airbnb.com/v2/threads?_format=for_messaging_sync&_limit=40&role=all&selected_inbox_type=host&locale=en-US&currency=EUR";
$arr = array(
"operations" => array(
array(
"method"=>"GET",
"path"=>"/calendar_days",
"query" => array(
"start_date"=>$start_date,
"listing_id"=>$listingId,
"_format"=>"host_calendar",
"end_date"=>$end_date,
)
),
array(
"method"=>"GET",
"path"=>"/dynamic_pricing_controls/".$listingId,
"query" => array()
)
),
"_transaction" => false
);
echo $this->curl($url, json_encode($arr));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment