I am a complete noob when working with APIs and PHP. I want to have the following code dump results into a file called books.json and I have no idea how to do it. Any help is greatly appreciated!
// Built by LucyBot. www.lucybot.com
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$query = array(
"api-key" => "MY APRI KEY"
);
curl_setopt($curl, CURLOPT_URL,
"https://api.nytimes.com/svc/books/v3/lists/best-sellers/history.json" . "?" . http_build_query($query)
);
$result = json_decode(curl_exec($curl));
echo json_encode($result);