Hi,
I just saw your message thanks to Eissa Jamil, who also shared this fix:
//this gets the latest 20 videos from youtube
function scs_ytap_getYtVideoListData($scs_apikey, $scs_channelId, $scs_noofvids, $scs_publishedAfter, $scs_publishedBefore)
{
//var_dump($scs_publishedAfter);
//var_dump($scs_publishedBefore);
$orderbydate = "&order=date";
if ($scs_publishedAfter != "") {$scs_publishedAfter = "&publishedAfter=" . $scs_publishedAfter . "T00%3A00%3A00.0Z";
$orderbydate = "";}
if ($scs_publishedBefore != "") {$scs_publishedBefore = "&publishedBefore=" . $scs_publishedBefore . "T00%3A00%3A00.0Z";
$orderbydate = "";}
$yturl = "https://www.googleapis.com/youtube/v3/search?key=" . $scs_apikey . "&channelId=" . $scs_channelId . "&part=snippet,id" . $orderbydate . "&maxResults=" . $scs_noofvids . $scs_publishedAfter . $scs_publishedBefore;
// echo $yturl;
$json = curl_get_contents($yturl);
//$json = file_get_contents($yturl); // failure here on my server
$data = json_decode($json, true);
// echo $data;
return $data;
}
function curl_get_contents($url,$useragent='cURL',$headers=false, $follow_redirects=false,$debug=false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($headers==true){
curl_setopt($ch, CURLOPT_HEADER,1);
}
if ($headers=='headers only') {
curl_setopt($ch, CURLOPT_NOBODY ,1);
}
if ($follow_redirects==true) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
if ($debug==true) {
$result['contents']=curl_exec($ch);
$result['info']=curl_getinfo($ch);
} else {
$result=curl_exec($ch);
}
curl_close($ch);
return $result;
}
Hope this will work for you as well. Thanks Eissa!