当我使用您的YouTube API卷曲方法(v3)时
$api_key = 'YOUR_API_KEY';
$url = 'https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&key=' . $api_key . '&forUsername=' . $_GET['username'];
// initializes the request
$curl = curl_init();
// sets the url
curl_setopt($curl, CURLOPT_URL, $url);
// enables that curl_exec() returns content instead of status code
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// allows redirects
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
// checks if a secure site has been requested
if(preg_match('/^https:\/\//', $url)){
// if so, verification is disabled
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
// performs the actual request
$data = curl_exec($curl);
// destructs the request
curl_close($curl);
// this line converts the json string which is returned into a php object
$data = json_decode($data);
print_r($data);
显示
Array (
[error] => Array (
[errors] => Array (
[0] => Array (
[domain] => youtube.parameter
[reason] => missingRequiredParameter
[message] => No filter selected.
[locationType] => parameter
[location] =>
)
)
[code] => 400
[message] => No filter selected.
)
)
为什么会出现这个错误?