2016-11-16 469 views
2

我們正在使用Instagram的oEmbed-API獲取嵌入代碼。但是,我們不希望完全依賴該API並自己生成嵌入代碼。由API(或網站)提供的嵌入代碼包含大量的html,css圖像數據和文本內容,在嵌入js之前,所有這些都必須在那裏。這是一個問題,因爲我們無法實現通用嵌入代碼,但必須事先知道每個照片或視頻的instagram內容。通過JavaScript嵌入Instagram

我的問題是:Ist有一個通用的嵌入代碼,像這樣,對於instagram?

<script async defer=\"defer\" src=\"//platform.instagram.com/en_US/embeds.js\"></script> 
<script>instgrm.Embeds.genenerate('some instragram ID for instance')<script/> 

回答

3

您可以使用iframe嵌入這樣的:

<iframe src="https://www.instagram.com/p/BFKjVxkBsCC/embed" width="400" height="480" frameborder="0" scrolling="no" allowtransparency="true"></iframe> 

加入/embed到Instagram的帖子的網址給你,可以嵌入

加入/embed/captioned將添加字幕的圖像

圖像

這裏是容易產生嵌入代碼的鏈接:https://www.picodash.com/instagram/embed#https://www.instagram.com/p/BFKjVxkBsCC/

+0

感謝但iFrames不是我們的選擇,它們在加載和渲染性能方面都很慢,並且通常很難使用esp。在手機上滑動瀏覽內容。 – Lukas

+0

嵌入你從腳本中獲得的腳本最終也會使用iframe。其他選項是使用Instagram API並獲取圖像鏈接並加載爲,但您需要進行身份驗證並獲取access_token並撥打電話:https://www.instagram.com/developer/endpoints/media/#get_media_by_shortcode – krisrak