2017-09-27 25 views
0

Ich bin ein wenig jQuery-Plugin für eine Wiedergabeliste youtube Start und ich habe Probleme die URL richtigyoutube api json url

Konstruktion

dies ist mein Code:

var playlist = { 
    playlist: '**', 
    apiKey: '**', 
    container: $('#test'), 
    shuffle: false 
} 

function player() { 
    var url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=$'+playlist.playlist+'&key=$'+playlist.apiKey+'&callback=?'; 
    console.log(url); 
    $.getJSON(url, function(result){ 
     $.each(result, function(){ 
      $('#test').append(); 
     }); 
    }); 
} 

und das ist, was die URL oben returns:

{"error":{"errors":[{"domain":"global","reason":"invalidParameter","message":"Invalid value for parameter callback: ","locationType":"parameter","location":"callback"}],"code":400,"message":"Invalid value for parameter callback: "}} 
+0

https://developers.google.com/youtube/v3/docs/playlistItems/list – Donal

Antwort

1

Sie müssen auf den Callback eine Funktion zum Ausführen setzen. Wenn Sie nichts wollen, können Sie einfach so falsch setzen &callback=false. Auf Ihrem Code wird es so sein:

var url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=$'+playlist.playlist+'&key=$'+playlist.apiKey+'&callback=false'; 

Ich hoffe, es hilft Ihnen.

Verwandte Themen