Why it's not working when querying the youtube API?

Hello! I found php code that makes a request to the youtube API. When you start nothing comes out(just NULL).
youtube_search function($apikey, $search, $limit){
 $search = urlencode($search);
 $url = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=$search&type=video&maxResults=$limit&regionCode=RU&key=$apikey";
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1");
 curl_setopt($ch, THIS, FALSE);
 curl_setopt($ch, CURLOPT_HEADER, false);
 // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //if the error falls on this line, try to comment out it
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_REFERER, $url);
 $out = curl_exec($ch);
 return $out;
$search = "Pokemon"; // Search query
$limit = 10; // Number of results
$apikey = "{ API_KEY }"; // Your key to the youtube api v3
$res_json = youtube_search($apikey, $search, $limit) ;
$res = json_decode( $res_json );

March 23rd 20 at 18:46
1 answer
March 23rd 20 at 18:48
unfortunately in this example, nothing is clear. - coralie.Bog commented on March 23rd 20 at 18:51
@coralie.BogUsed it? work? - bennett commented on March 23rd 20 at 18:54
I certainly wildly apologize, but in Your initial code You have it is and try to run, or the data is still of some con? At least interests $apikey, because "pokemon" You still are, then You're back to insert your API key, right? - bennett commented on March 23rd 20 at 18:57
@bennett, I found another code (also with curl). This is already working. - coralie.Bog commented on March 23rd 20 at 19:00
If for example the link straight after, nothing is clear, maybe you should think about changing profession? In the manual, everything is in detail chewed. Don't even imagine that there might be confusion. - kevon.Schuppe26 commented on March 23rd 20 at 19:03

Find more questions by tags APIPHP