Почему получаю ошибку?
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyExpired",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
Мой код. мне надо вытащить идентификаторы из плей листа и записать в базу
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.js"></script>
<title>Document</title>
</head>
<body>
<input type="text" value="PLTI6yRvQqlYq9KoU-NHu43uDmKON7Fsjv" id="searchtext1" size="75">
<button onclick="getVids()">Get Items</button>
<br><br>
<br><br>
<textarea id="area1" style="width:300px;height:500px"> </textarea>
<textarea id="area12" style="width:300px;height:500px;position: relative;float: left"> </textarea>
<script>
sum = 0;
sumN = 1;
var nextPageToken;
function getVids(PageToken){
pid = $('#searchtext1').val();
$.get(
"https://www.googleapis.com/youtube/v3/playlistItems",{
part : 'snippet',
maxResults : 50,
playlistId : pid,
pageToken : PageToken,
key: 'Мой токен'
},
function(data){
myPlan(data);
}
);
}
function myPlan(data){
total = data.pageInfo.totalResults;
nextPageToken=data.nextPageToken;
for(i=0;i<data.items.length;i++){
document.getElementById('area1').value +=
sumN + '-' + data.items[i].snippet.title+'\n'+
data.items[i].snippet.resourceId.videoId +'\n\n';
var url = data.items[i].snippet.resourceId.videoId;
$.ajax({
type: "POST",
url: "2.php",
data: {myData: url},
success: function (response) {
document.getElementById('area12').value +=response.length+'-' +response+ "-Ok!!!"+'\n\n';
}
});
sum++ ; sumN++;
if(sum == (total-1) ){
sum = 0;
return;
}
}
if(sum <(total-1)){
getVids(nextPageToken);
}
}
function init(){
$('#area1').val('');
}
</script>
</body>
</html>