Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 通过https检索YouTube订户缩略图_Html_Ajax_Youtube Api - Fatal编程技术网

Html 通过https检索YouTube订户缩略图

Html 通过https检索YouTube订户缩略图,html,ajax,youtube-api,Html,Ajax,Youtube Api,是否可以显示通过https而不是http订阅提要的嵌入式YouTube播放列表的缩略图 我在一个https站点的某个区域工作,通过http检索这些缩略图会导致弹出一个安全警告,我正试图将其清除 缩略图是YouTube API的一部分,因此无法通过https直接请求缩略图: // loop through JSON and assign values to My obj for (var i = 0; i < len; i ++ ) { TheVid

是否可以显示通过https而不是http订阅提要的嵌入式YouTube播放列表的缩略图

我在一个https站点的某个区域工作,通过http检索这些缩略图会导致弹出一个安全警告,我正试图将其清除

缩略图是YouTube API的一部分,因此无法通过https直接请求缩略图:

// loop through JSON and assign values to My obj
        for (var i = 0; i < len; i ++ ) {

            TheVideo.My[i] = {};
            ja = jsonArticles[0][i];

            TheVideo.My[i].img = ja.media$group.media$thumbnail[0].url;

        }
//循环JSON并为我的obj赋值
对于(变量i=0;i
我直接寻找的是在上面最后一行调用.url时从https而不是http调用缩略图

编辑:


我找到了解决这个问题的方法,但我编辑了我的原始帖子,澄清了一点问题所在。

答案有点像是附加内容,但它确实起到了作用。我附加了一个replace方法来从https而不是http请求它:

// loop through JSON and assign values to My obj
        for (var i = 0; i < len; i ++ ) {

            TheVideo.My[i] = {};
            ja = jsonArticles[0][i];

            TheVideo.My[i].img = ja.media$group.media$thumbnail[0].url.replace('http://','https://');

        }
//循环JSON并为我的obj赋值
对于(变量i=0;i
很高兴知道在这种情况下这是可能的

希望这有可能为其他人回答问题