“https://unogsng.p.rapidapi.com/search?newdate=$lastWeek&orderby=date&audio=english”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “GET”,
CURLOPT_HTTPHEADER => array(
“x-rapidapi-host: unogsng.p.rapidapi.com”,
“x-rapidapi-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
if ($debug) echo “cURL Error #:” . $err;
else echo “Oops, something went wrong. Please try again later.”;
} else {
//Create an array of objects from the JSON returned by the API
$jsonObj = json_decode($response);
//Reorder the items so the newest releases are first
$newestReleasesFirst = array_reverse($jsonObj->results);
//Create a simple grid style for the listings
$pageCSS = “
“;
//Create the WordPress page content HTML
$pageHTML=”
Netflix releases since $lastWeek (in English)
“;
$pageHTML.=”
//Loop through the API results
foreach($newestReleasesFirst as $showObj) {
//Put each show into an html structure
// Note: if your theme uses bootstrap use responsive classes here
$pageHTML.=”
//Not all items have a ‘poster’, so in that case use the img field
if (!empty($showObj->poster)) $thisImg = $showObj->poster;
else $thisImg = $showObj->img;
//Show the image first to keep the top edge of the grid level
$pageHTML.=”“;
$pageHTML.=”
“.$showObj->title.”
“;
$pageHTML.=”added to netflix “.$showObj->titledate.”“;
$pageHTML.=”
“;
$pageHTML.=”
“;
}
$pageHTML.=”
“;
echo $pageCSS.$pageHTML;
} // end of check for curl error
?>