J
J
jynj2016-11-29 08:32:34
YouTube
jynj, 2016-11-29 08:32:34

What's wrong with the API?

function send_req($url)
{
$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, CURLOPT_SSL_VERIFYPEER, 		FALSE);
curl_setopt($ch, CURLOPT_HEADER,				false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,		true);
curl_setopt($ch, CURLOPT_URL,					$url);
curl_setopt($ch, CURLOPT_REFERER,				$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,		TRUE);
$out = curl_exec($ch);
curl_close($ch);
return $out;
}

$url = "https://www.googleapis.com/youtube/v3/search?sp=CAM%253D&part=snippet&q=$name&type=video&maxResults=3&key=ключ";
$res = json_decode(send_req($url));

echo "<pre>";
print_r($res);
echo "</pre>";

It is the URL that is of interest, if you select the item on Youtube itself, output by the number of views, then this is added &sp=CAM%253D, and if by the date of loading &sp=CAI%253D, inserted into any places of the request, but they do not work, what to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2016-11-29
@jynj

YouTube, like most services, does not work through its open API, so it is very naive to expect that everything will be identical, learn how to use the documentation for the open API and find the answer,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question