2017-02-15 74 views
0

Google youtube API无法通过错误的请求和无效的密码登录 我几次在Google控制台更新我的凭据。Google youtube API无法通过错误的请求和无效的密码登录

更改API键几次但问题都是一样的。

使用的代码I'm:

var channelname = 'mipaltan'; 
 

 
$(document).ready(function() { 
 
    $.get("https://www.googleapis.com/youtube/v3/channels", { 
 
     part: 'contentDetails', 
 
     forUsername: 'mipaltan', 
 
     key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg' 
 
    }, 
 
\t function (data) { 
 
\t  $.each(data.item, function (i, item) { 
 
\t   console.log(item); 
 
\t   pid = item.contentDetails.relatedPlaylists.uploads; 
 
\t   getVids(pid); 
 
\t  }) 
 
\t } 
 
); 
 
    function getVids(pid) { 
 
     $.get("https://www.googleapis.com/youtube/v3/playlistItems", { 
 
      part: 'snippet', 
 
      maxResults: 10, 
 
      playListId: pid, 
 
      key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg' 
 
     }, 
 

 
     function (data) { 
 
      var output; 
 
      $.each(data.items, function (i, item) { 
 
       console.log(item); 
 
       vidsTitle = item.snippet.title; 
 

 
       output = '<li>"+ vidsTitle +"</li>'; 
 
       // Append to results 
 
       $('#results').append(output); 
 
       }) 
 
     } 
 
\t); 
 
    } 
 
});
<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head runat="server"> 
 
    <title> Get Video Title</title> 
 
<style> 
 
body { 
 
    background: #f4f4f4; 
 
    font-family: Arial,sans-serif; 
 
    font-size: 14px; 
 
    color: #666; 
 
} 
 
#container 
 
{ 
 
    width: 100%; 
 
    height: auto; 
 
    overflow:auto; 
 
    margin: auto; 
 
\t padding:15px; 
 
} 
 
</style> 
 
    <script src="http://code.jquery.com/jquery-1.11.1.js"></script> 
 
     <script src="js/script.js"></script> 
 
    </head> 
 

 
    
 
    <body> 
 
     <form id="form1" runat="server"> 
 
     <div id="container"> 
 
      <h1> YouTube Video Title</h1> 
 
      <ul id="results"></ul> 
 
     </div> 
 
     </form> 
 
    </body> 
 
    
 

 
</html>

同样的API密钥我使用的是其他网页它的正常工作。

回答

0

其项目不是项目,playlistId不playListId

var channelname = 'mipaltan'; 
 

 
$(document).ready(function() { 
 
    $.get("https://www.googleapis.com/youtube/v3/channels", { 
 
     part: 'contentDetails', 
 
     forUsername: 'mipaltan', 
 
     key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg' 
 
    }, 
 
    function(data) { 
 
     $.each(data.items, function(i, item) { 
 
     pid = item.contentDetails.relatedPlaylists.uploads; 
 
     getVids(pid); 
 
     }) 
 
    } 
 
); 
 

 
    function getVids(pid) { 
 
    $.get("https://www.googleapis.com/youtube/v3/playlistItems", { 
 
     part: 'snippet', 
 
     maxResults: 10, 
 
     playlistId: pid, 
 
     key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg' 
 
     }, 
 

 
     function(data) { 
 
     $.each(data.items, function(i, item) { 
 
      vidsTitle = item.snippet.title; 
 
      output = '<li>'+ vidsTitle +'</li>'; 
 
      // Append to results 
 
      $('#results').append(output); 
 
     }) 
 
     } 
 
    ); 
 
    } 
 
});
body { 
 
     background: #f4f4f4; 
 
     font-family: Arial, sans-serif; 
 
     font-size: 14px; 
 
     color: #666; 
 
    } 
 
    #container { 
 
     width: 100%; 
 
     height: auto; 
 
     overflow: auto; 
 
     margin: auto; 
 
     padding: 15px; 
 
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
    <form id="form1" runat="server"> 
 
    <div id="container"> 
 
     <h1> YouTube Video Title</h1> 
 
     <ul id="results"></ul> 
 
    </div> 
 
    </form>

+0

非常感谢你,我亲爱的朋友们,我不是忘了你, –

+0

不要忘记点击接近我的回答绿色的复接受它 – madalinivascu

相关问题